DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

CIARANA
CIARANA

Posted on • Updated on

Is golangci-lint Generics Readiness?

This post is Day 24 of Go Advent Calendar 2021(jp). πŸŽ„πŸŽ…


golangci-lint is easy to use a very large of linters with a configuration file. On the other hand, it depends on a lot of linters, which makes it difficult to incorporate the latest implementations of them. Also, many of them have not been updated for some time. In such a situation, Go could introduce Generics at any moment. So I checked whether the linters support Generics or not, and summarized the results in the following list. In order to check if each linter supports or is going to support Generics, I search the issues and pull requests from the last 6 months using the keywords "generics", "type" and "1.18".


Name Status Remark
deadcode ⬜ no update for 5 years
errcheck ⬜ -
gosimple ⬜ -
govet βœ… https://tip.golang.org/doc/go1.18#vet
ineffassign ⬜ -
staticcheck ⬜ issue exists but not yet supported
structcheck ⬜ no update for 3 years(Reference to the package changed from GitHub to GitLab.οΌ‰
typecheck ⬜ -
unused ⬜ -
varcheck ⬜ same as structcheck
asciicheck ⬜ -
bidichk ⬜ -
bodyclose ⬜ -
contextcheck ⬜ -
cyclop ⬜ -
depguard ⬜ -
dogsled ⬜ -
dupl ⬜ -
durationcheck ⬜ -
errchkjson ⬜ -
errname ⬜ -
errorlint ⬜ -
exhaustive ⬜ There is no indication of how it will be implemented, but there is an issue that talks about the need to update it.
exhaustivestruct ⬜ -
exportloopref ⬜ -
forbidigo ⬜ -
forcetypeassert ⬜ -
funlen ⬜ no update for a year
gci ⬜ -
gochecknoglobals ⬜ -
gochecknoinits ⬜ -
gocognit ⬜ -
goconst ⬜ -
gocritic ⬜ Previously fixed error is recurring.
gocyclo ⬜ -
godot ⬜ -
godox ⬜ issue tab is hidden
goerr113 ⬜ -
gofmt βœ… Referencing standard packages via golangci/gofmt, so some may not be supported.
gofumpt βœ… https://github.com/mvdan/gofumpt/releases/tag/v0.2.0
goheader ⬜ -
goimports βœ… same as gofmt
golint ⬜ deprecated and archived
gomnd ⬜ -
gomoddirectives ⬜ -
gomodguard ⬜ -
goprintffuncname ⬜ no update for 2 years
gosec ⬜ -
ifshort ⬜ -
importas ⬜ -
interfacer ⬜ deprecated and archived
ireturn ⬜ -
lll ⬜ -
makezero ⬜ -
maligned ⬜ deprecated and archived
misspell ⬜ no update for 4 years
nakedret ⬜ -
nestif ⬜ -
nilerr ⬜ no update for a year
nilnil ⬜ -
nlreturn ⬜ -
noctx ⬜ -
nolintlint ⬜ -
paralleltest ⬜ -
prealloc ⬜ -
predeclared ⬜ -
promlinter ⬜ -
revive ⬜ -
rowserrcheck ⬜ -
scopelint ⬜ deprecated and archived
sqlclosecheck ⬜ -
stylecheck ⬜ -
tagliatelle ⬜ -
tenv ⬜ -
testpackage ⬜ -
thelper ⬜ -
tparallel ⬜ -
unconvert ⬜ no update for 2 years
unparam ⬜ There is an issue that states that x/tools/go/ssa supports Generics and then supports it.
varnamelen ⬜ -
wastedassign ⬜ https://github.com/sanposhiho/wastedassign/issues/41
whitespace ⬜ -
wrapcheck βœ… https://github.com/tomarrell/wrapcheck/commit/213318509af6a003be2be752da826d269149ba4d
wsl ⬜ -

Currently, most of the linters do not yet support Generics, and few of them have taken any action to support it. Even if the various linters support Generics, the latest golangci-lint will probably support it in due course. The reason for the lack of support may be that the official x/tools, including go/ssa, do not yet support Generics1. Therefore, for production services that use golangci-lint regularly, it is better to experiment with Generics in the development environment only, and wait for a while before using it in the production environment. Conversely, it might be a chance to contribute them;)

There may be linters that do not fail with or without Generics. Also, some of them may actually support Generics due to my lack of confirmation, and some of them may support Generics after this post was published because I couldn't keep up with the latest information. In that case, please let me know in the comments.


  1. https://github.com/golang/go/issues/48525 ↩

Top comments (0)

DEV

Thank you.

Β 
Thanks for visiting DEV, we’ve worked really hard to cultivate this great community and would love to have you join us. If you’d like to create an account, you can sign up here.