TIL: standalone linters for Go

Tom Deneire
2 min readJul 7, 2023
Photo by Nong on Unsplash

Standalone linting

Today I looked at some option for standalone linting of Go code. What I mean by that is linting that is not done in an editor or IDE like Goland. Not that there’s anything wrong with that — Goland has really good linting, so I’ve seen — but I like to use linting independently, as part of the build process, and also capture the output.

go vet

The first option I looked at was the built-in command go vet (run go vet ./... in the root folder of your project).

Although it has more than 20 analyzers enabled by default (you can check with go tool vet help), this was still the option that got me the least results (9 lines) for the code-base I’m testing this on, which is about 50,000 lines. By the way, try find . -name ‘.go’ | xargs wc -lfor counting.

go vet also has an option to get the command output in JSON, which is interesting for further use.


Next, I looked at staticcheck: