Skip to content

Commit

Permalink
Remove redundant variable copying in for loops (#473)
Browse files Browse the repository at this point in the history
With the release of Go 1.22, it's no longer necessary to manually copy loop variables inside for loops.

Signed-off-by: Marko Lukša <[email protected]>
  • Loading branch information
luksa authored Nov 12, 2024
1 parent 7bc6182 commit e195a23
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion common/config/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ linters:
disable-all: true
enable:
- errcheck
- exportloopref
- copyloopvar
- depguard
- gocritic
- gofumpt
Expand Down
2 changes: 0 additions & 2 deletions controllers/istio/istio_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ func TestDetermineStatus(t *testing.T) {

initObjs := []client.Object{istio}
for _, rev := range tc.revisions {
rev := rev
initObjs = append(initObjs, &rev)
}

Expand Down Expand Up @@ -728,7 +727,6 @@ func TestUpdateStatus(t *testing.T) {

initObjs := []client.Object{istio}
for _, rev := range tc.revisions {
rev := rev
initObjs = append(initObjs, &rev)
}

Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/controlplane/control_plane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ metadata:

Describe("given Istio version", func() {
for _, version := range supportedversion.List {
// Note: This var version is needed to avoid the closure of the loop
version := version

Context(version.Name, func() {
BeforeAll(func() {
Expect(k.CreateNamespace(controlPlaneNamespace)).To(Succeed(), "Istio namespace failed to be created")
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/dualstack/dualstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ var _ = Describe("DualStack configuration ", Ordered, func() {

Describe("for supported versions", func() {
for _, version := range supportedversion.List {
// Note: This var version is needed to avoid the closure of the loop
version := version

// The minimum supported version is 1.23 (and above)
if version.Version.LessThan(semver.MustParse("1.23.0")) {
continue
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/api/istio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ var _ = Describe("Istio resource", Ordered, func() {
})

for _, withWorkloads := range []bool{true, false} {
withWorkloads := withWorkloads

Context(generateContextName(withWorkloads), func() {
if withWorkloads {
BeforeAll(func() {
Expand Down

0 comments on commit e195a23

Please sign in to comment.