Description
Your feature request related to a problem? Please describe.
Some linters have different behavior based on the go version we use.
For instance, staticcheck disable SA3000 (os.Exit(m.Run()) required) from go 1.15+ as now upstream golang is storing the return code internally and this is not needed anymore.
However, golangci-lint assumes go 1.13 by default, (seen in https://golangci-lint.run/usage/configuration/):
staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.15"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
making the some users confused: dominikh/go-tools#708 (comment).
In addition, multiple linters are in that situation and repeating the version in different places don’t seem optimal.
Describe the solution you'd like.
golangci-lint could extract from go.mod the go version used and inject on all those linters which expects a go version to follow it.
The config file could still set different go version by impacted linters to override this default.
Describe alternatives you've considered.
The other alternative is to specify on the golangci-lint command line a go version to inject, but it seems that removing one step and aligning the project on base go.mod could be a better user experience.
Nothing prevents an command line override the automated go.mod version detection though.
Additional context.
No response