-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use go.mod "go" version stenza to inject go version in linters #2234
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Can be linked to #2158 |
We planned to change the default in the v2: golangci-lint/pkg/golinters/staticcheck_common.go Lines 27 to 28 in 813ba7d
|
You might be interested in dominikh/go-tools@c5ce990 |
@dominikh So, what you are saying that it's better not to use I've checked, and This approach is probably the way, but do we have packages loaded somewhere when we execute Or we should just try to parse Asking, because I was recently annoyed by SA3000 warning from staticcheck, almost created a bug ticket for it, and was not aware that I have to configure go version for each linter, so having this would be very useful. |
close by #2913 |
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/):
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
The text was updated successfully, but these errors were encountered: