-
Notifications
You must be signed in to change notification settings - Fork 21
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 1.22 language features. #488
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reads well.
This seems entirely pointless though. It needlessly requires anyone who might want to pull in the vpsd module to force their own consumers to a minimum of Go 1.22 for a feature that provides zero benefit.
Thats why I opened this as a separate PR, I am still in two minds about it. IMO updating the for loops is worthwhile because it tidies up the code and removes the chance of off-by-one errors (and other bugs), but I'm not sure it merits a version bump on its own. Perhaps this PR can remain open as a TODO, to be revisited on the next go version bump. |
I guess I'm just too used to normal for loops, but I find them more obvious and less error prone than the new syntax myself. When I see a range, it requires thinking about whether it's the index or the value (like in maps) which means looking at the type of the target of the range and remembering which inconsistent semantics are at play. Then, there is the whole change so that the loop variable is per-iteration scope instead of per-loop scope in Go 1.22 which means the On the other hand, |
Newly introduced copyloopvar linter does not run unless go.mod files are updated. |
Based on #487