-c Run in docker and don't worry about dependencies
-w Automatically fix all formatting issues
-d Print diff for all formatting issues
-l List files that have formatting issues
-g Format output to be parsed by github actions
EOF
}
format(){
if["$GOIMPORTS_ARGS"==""];then
GOIMPORTS_ARGS="-l"
fi
# only -l supports output as github action
if["$GITHUB_ACTION"=="true"];then
GOIMPORTS_ARGS="-l"
fi
# Check for dependencies
if ! command -v goimports >/dev/null 2>&1;then
printf"%s\n""Require goimports. You can run this command in a docker container instead with '-c' and not worry about it or install it: \n\tgo install golang.org/x/tools/cmd/goimports@latest" >&2
exit1
fi
# Use -exec because of pitfall #1 in http://mywiki.wooledge.org/BashPitfalls
GOFMT_OUTPUT="$(echo"$GOFMT_OUTPUT"| awk '{print "::error file="$0"::Formatting error. Please format using ./scripts/lint.sh -d format."}')"
fi
echo"$GOFMT_OUTPUT" >&2
exit1
fi
}
lint(){
# Check for dependencies
if ! command -v golangci-lint >/dev/null 2>&1;then
printf"%s\n""Require golangci-lint. You can run this command in a docker container instead with '-c' and not worry about it or install it: https://golangci-lint.run/usage/install/"
fi
# Do the actual linting!
cd"$ROOT"/node
golangci-lint run --skip-dirs pkg/supervisor --timeout=10m --path-prefix=node $GOLANGCI_LINT_ARGS ./...