-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add loopvar linter #4182
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
feat: add loopvar linter #4182
Conversation
Signed-off-by: karamaru-alpha <mrnk3078@gmail.com>
Hey, thank you for opening your first Pull Request ! |
Signed-off-by: karamaru-alpha <mrnk3078@gmail.com>
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
Pull Request Description
Linter
The Linter Tests Inside Golangci-lint
|
Signed-off-by: karamaru-alpha <mrnk3078@gmail.com>
Antagonist of #1404. |
@Antonboom |
I'd like to add https://github.com/karamaru-alpha/loopvar.
This linter detects places where loop variables are copied.
For Go 1.21(set GOEXPERIMENT=loopvar) and Go 1.22~, it is unnecessary to copy loop variables because these variables have per-iteration scope instead of per-loop scope.
I understand that introducing this linter might be a bit premature, but I added it thinking it will be useful in the future.
cf. Fixing For Loops in Go 1.22
golangci-lint run --no-config --disable-all -E loopvar ./test/testdata/loopvar.go