-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Upgrade to go 1.22 #3573
Comments
As you may already know, by using a linter called To enable diff --git a/.golangci.yml b/.golangci.yml
index 85a95650..5b7c5e32 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -14,6 +14,7 @@ linters:
- exhaustive
- makezero
- nakedret
+ - copyloopvar
# - goconst # TODO: enable and fix issues
fast: false For example, if there was unnecessary assignment, output is like this: $ golangci-lint run -c ./.golangci.yml ./...
pkg/app/app.go:161:3: The copy of the 'for' variable "repoDir" can be deleted (Go 1.22+) (copyloopvar)
repoDir := repoDir
^ |
Ah nice! Would you be up to raising a PR for that @kyu08 ? |
Sure! I'd be happy to do that. 👍 |
Awesome, thanks |
Resolves #3573 It looks like the update to go1.22 is done by #3574. So it should be OK to close #3573 when this PR is merged. ## PR Description Add [`copyloopvar`](https://github.com/karamaru-alpha/copyloopvar) to enabled linters to detect unnecessary assignments in `for` loops. ## Context @jesseduffield and I were talking about necessity of this linter here. #3573 (comment)
Is your feature request related to a problem? Please describe.
go 1.22 is out and notably it updates the way that loops are handled:
This is a very good improvement: it means we don't need to say
x := x
on the first line of any loop in whichx
will be closed over by a function. The reason I'm raising this issue is because just now I had a bug because I forgot to addx := x
myself!Describe the solution you'd like
Let's upgrade to go 1.22 and go find all the places we're doing
x := x
in loops and delete those lines.The text was updated successfully, but these errors were encountered: