diff --git a/go/README.md b/go/README.md index 47be7e20..aa3c5a15 100644 --- a/go/README.md +++ b/go/README.md @@ -7,8 +7,9 @@ ### Go Linters -- `DISABLE_GOVULNCHECK`: Set to skip running govulncheck -- `DISABLED_GOLANGCI_LINTERS`: Linters to disable in golangci-lint +- `DISABLE_GOVULNCHECK`: Set to skip running [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck) +- `DISABLED_GOLANGCI_LINTERS`: Linters to disable in [golangci-lint](https://github.com/golangci/golangci-lint) +- `DISABLE_NILAWAY`: Set to skip running [nilaway](https://github.com/uber-go/nilaway) - `GOLANGCI_LINTERS`: List of additional [Go linters to run with golangci-lint](https://golangci-lint.run/usage/linters/). (Example: `gosec`) - `SKIP_GOLANGCI`: Don't run the golangci-lint checks - `STRICT_GOLANGCI_LINTERS`: Enable more linters packaged with golangci-lint diff --git a/go/lint-project.sh b/go/lint-project.sh index 6c90f3f8..4b33e759 100755 --- a/go/lint-project.sh +++ b/go/lint-project.sh @@ -215,6 +215,27 @@ if [[ "$run_xmlencoderclose" == "true" ]]; then fi fi +if [[ "$EXPERIMENTAL" == *"nilaway"* ]]; +then + # nilaway can deliver false positives so it's not currently allowed inside of golangci-lint, + # however this linter is useful so we offer it. + # + # https://github.com/golangci/golangci-lint/issues/4045 + + # Install nilaway + go install go.uber.org/nilaway/cmd/nilaway@latest + + # Find the linter + bin="" + if which -s nilaway > /dev/null; + then + bin=$(which nilaway 2>&1 | head -n1) + fi + + # Run nilaway + "$bin" -test=false ./... +fi + # golangci-lint if [[ "$org" == "moov-io" ]]; then diff --git a/makefile b/makefile index 52bf2ea9..d6f22720 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ PLATFORM=$(shell uname -s | tr '[:upper:]' '[:lower:]') .PHONY: check check: - EXPERIMENTAL=gitleaks,govulncheck,shuffle \ + EXPERIMENTAL=gitleaks,govulncheck,nilaway,shuffle \ COVER_THRESHOLD=80.0 \ GOCYCLO_LIMIT=15 \ GOLANGCI_FLAGS="--exclude-use-default=false" \