The New Golangci-lint: Even More Faster
Published in
2 min readNov 24, 2018
In the last month, we’ve released two versions of golangci-lint with a lot of new features: v1.11 and v1.12.
What’s New
I will list the biggest changes.
Go/packages Support
The library go/packages is the program loader, it is the replacement of older go/loader. Golangci-lint uses the program loader to parse the whole program: extract AST, type information and then build SSA if needed. Both libraries are official libraries, but the new one has some killer features:
- it supports loading type information from a go build cache: because of that almost all linters became “fast”: they work in 1–2 seconds. Only unparam, interfacer and megacheck are “slow” linters now. An average project is analyzed 20–40% faster than before if all linters are
enabled! If we enable all linters except unparam, interfacer and
megacheck the analysis is 10–20x faster! - it supports go modules: now we can analyze repos outside of GOPATH.
- it supports more build systems: not only go build, but e.g. bazel
Change The License From AGPL to GPL
Some organizations disallow the usage of open-source projects with AGPL license. We’ve changed the license to GPL.
New Linters
We’ve supported 4 cool linters:
- go-critic: the most opinionated Go source code linter for code audit.
- scopelint: checks for unpinned variables in go programs.
- gochecknoinits: checks that no init functions are present in Go code.
- gochecknoglobals: checks that no globals are present in Go code.
Other Changes
- support exclude flags for errcheck
- update imports formatting: use the new goimports
- support local-prefix option for goimports: it puts imports beginning with this option after 3rd-party packages