Uh oh!
There was an error while loading. Please reload this page.
golangci-lint: set go version to prevent fallback to go1.17, and fix copyloopvar linting issues - #5594
Conversation
…opvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…opvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…pvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…oopvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…pvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…var) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; cli/command/image/tree.go:59:4: The copy of the 'for' variable "im" can be deleted (Go 1.22+) (copyloopvar) im := im ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…oopvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; cli/command/container/opts.go:765:3: The copy of the 'for' variable "n" can be deleted (Go 1.22+) (copyloopvar) n := n ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…var) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; cli/compose/loader/merge.go:71:3: The copy of the 'for' variable "overrideService" can be deleted (Go 1.22+) (copyloopvar) overrideService := overrideService ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…pvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; cli/command/service/update.go:1061:3: The copy of the 'for' variable "entry" can be deleted (Go 1.22+) (copyloopvar) entry := entry ^ cli/command/service/update.go:1089:4: The copy of the 'for' variable "port" can be deleted (Go 1.22+) (copyloopvar) port := port ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…pvar) go1.22 and up now produce a unique variable in loops, tehrefore no longer requiring to capture the variable manually; cli-plugins/manager/cobra.go:55:4: The copy of the 'for' variable "p" can be deleted (Go 1.22+) (copyloopvar) p := p ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
GolangCI-lint attempts to deduct the Go version to lint for through the go version specified in go.mod, which we don't have, and therefore it falls back to go1.17 semantics: level=warning msg="[linters_context] copyloopvar: this linter is disabled because the Go version (1.17) of your project is lower than Go 1.22 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## master #5594 +/- ##
==========================================
- Coverage 59.63% 59.63% -0.01%
==========================================
Files 346 346 Lines 29214 29208 -6 ==========================================
- Hits 17421 17417 -4 + Misses 10824 10822 -2
Partials 969 969 |
| return | ||
| } | ||
| for _, p := range plugins { | ||
| p := p |
There was a problem hiding this comment.
just adding this here for future reference: https://go.dev/ref/spec#For_statements
Go 1.22 fixed iterations to use their own variables instead of sharing them. https://go.dev/ref/spec#Go_1.22
There was a problem hiding this comment.
Thanks for linking that! Yes, indeed, they fixed that situation. I know they had some back-and-forth on fixing it, because it could be a breaking change, but ultimately they decided that fixing the "footgun" part outweighed the "breaking change" part.
There was a problem hiding this comment.
I realised we were also setting go: build-tags; not exactly sure if those would affect the behavior (i.e., if go would downgrade to go1.21 semantics, and thus disable the new behavior), but just in case it would, I opened a PR to update those;
GolangCI-lint attempts to deduct the Go version to lint for through the
go version specified in go.mod, which we don't have, and therefore it
falls back to go1.17 semantics:
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)