Re:Improving Go code: An introduction to the static analysis...
by dgellow on Monday November 11, 2019 @05:55AM
(#21503742)
golangci-lint is just awesome. We started enabling it on all our repositories in combination with https://github.com/reviewdog/action-golangci-lint to have Github check warnings integration directly in the PR diff.
Also, it is now available as a choice of Go linter in Visual Studio Code.
This and also gosec are invaluable!
Something I looked recently and should adopt soon: https://github.com/golangci/golangci-lint
So far, this is what my 'de facto' lint list looks like:
echo "Checking for unchecked errors." errcheck $(go list ./...) echo "Linting code." test -z "$(golint `go list ./...` | tee /dev/stderr)" echo "Examining source code against code defect." go vet $(go list ./...) go vet -vettool=$(which shadow) echo "Running staticcheck toolset https://staticcheck.io" staticcheck ./... echo "Checking if code contains security issues." # TODO(henvic) fix/update gosec when available: # G104: Doesn't understand _ assignments #270 # https://github.com/securego/gosec/issues/270 # Ignoring G104: Audit errors not checked for now. gosec -quiet -exclude G104 --quiet ./...