Skip to main content
ertius.org

golangci-lint complexity

golangci-lint is a linter for Go. It's a wrapper around a bunch of other linters, and works quite well, and has a default config and installable tool for VS Code. It does, however, default to running itself with the --fast flag, which skips some more expensive checks, including useful ones like "this thing returns an err and you forgot to check it", which is unfortunate. It's also different to what it will run, with the same config file, when run in CI, since that will run all the checks.

So, if you're using golangci-lint in CI, you will get different results from what you get locally, which is not great. I'm not quite sure what to do about this. The obvious-to-me ideas aren't great: making it run locally without --fast is noticeable slower in my editor, a local git pre-commit hook doesn't surface output very usefully, isn't easily transferable between machine and isn't necessarily when I want to deal with things, a manual step a pain that I will definitely fail to run.

Maybe a git pre-push hook would suck less?