From b5aefe07e5afe2fd5d49c6a4219cc826b3e4e34e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 14 Oct 2025 11:40:26 +0200 Subject: all: remove unnecessary loop variable copies in tests Copying the loop variable is no longer necessary since Go 1.22. Change-Id: Iebb21dac44a20ec200567f1d786f105a4ee4999d Reviewed-on: https://go-review.googlesource.com/c/go/+/711640 Reviewed-by: Florian Lehner Auto-Submit: Damien Neil Reviewed-by: Dmitri Shuralyov Reviewed-by: Damien Neil Auto-Submit: Tobias Klauser LUCI-TryBot-Result: Go LUCI --- src/testing/flag_test.go | 1 - src/testing/panic_test.go | 1 - src/testing/sub_test.go | 1 - 3 files changed, 3 deletions(-) (limited to 'src/testing') diff --git a/src/testing/flag_test.go b/src/testing/flag_test.go index 6a7754425d..fb65e15928 100644 --- a/src/testing/flag_test.go +++ b/src/testing/flag_test.go @@ -25,7 +25,6 @@ func TestFlag(t *testing.T) { testenv.MustHaveExec(t) for _, flag := range []string{"", "-test.v", "-test.v=test2json"} { - flag := flag t.Run(flag, func(t *testing.T) { t.Parallel() cmd := exec.Command(testenv.Executable(t), "-test.run=^TestFlag$", "-test_flag_arg="+flag) diff --git a/src/testing/panic_test.go b/src/testing/panic_test.go index fc84175ee6..01a34b0801 100644 --- a/src/testing/panic_test.go +++ b/src/testing/panic_test.go @@ -198,7 +198,6 @@ func TestPanicHelper(t *testing.T) { } }) for i := 0; i < 3; i++ { - i := i t.Run(fmt.Sprintf("%v", i), func(t *testing.T) { chosen := t.Name() == *testPanicTest if chosen && *testPanicCleanup { diff --git a/src/testing/sub_test.go b/src/testing/sub_test.go index bb5586d9fc..5d5573ccec 100644 --- a/src/testing/sub_test.go +++ b/src/testing/sub_test.go @@ -988,7 +988,6 @@ func TestConcurrentCleanup(t *T) { var wg sync.WaitGroup wg.Add(2) for i := 0; i < 2; i++ { - i := i go func() { t.Cleanup(func() { // Although the calls to Cleanup are concurrent, the functions passed -- cgit v1.3