diff --git a/src/cmd/api/api_test.go b/src/cmd/api/api_test.go index 98ebf168ef3949..784bdb74e428e0 100644 --- a/src/cmd/api/api_test.go +++ b/src/cmd/api/api_test.go @@ -232,7 +232,6 @@ var warmupCache = sync.OnceFunc(func() { // Warm up the import cache in parallel. var wg sync.WaitGroup for _, context := range contexts { - context := context wg.Add(1) go func() { defer wg.Done() diff --git a/src/cmd/cgo/internal/testerrors/errors_test.go b/src/cmd/cgo/internal/testerrors/errors_test.go index 80d2c402cec0c2..aa61577ea3cb39 100644 --- a/src/cmd/cgo/internal/testerrors/errors_test.go +++ b/src/cmd/cgo/internal/testerrors/errors_test.go @@ -152,7 +152,6 @@ func TestToleratesOptimizationFlag(t *testing.T) { "", "-O", } { - cflags := cflags t.Run(cflags, func(t *testing.T) { testenv.MustHaveGoBuild(t) testenv.MustHaveCGO(t) diff --git a/src/cmd/cgo/internal/testsanitizers/asan_test.go b/src/cmd/cgo/internal/testsanitizers/asan_test.go index cb7d857280416f..a2d420402018e7 100644 --- a/src/cmd/cgo/internal/testsanitizers/asan_test.go +++ b/src/cmd/cgo/internal/testsanitizers/asan_test.go @@ -48,7 +48,6 @@ func TestASAN(t *testing.T) { {src: "arena_fail.go", memoryAccessError: "use-after-poison", errorLocation: "arena_fail.go:26", experiments: []string{"arenas"}}, } for _, tc := range cases { - tc := tc name := strings.TrimSuffix(tc.src, ".go") t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/src/cmd/cgo/internal/testsanitizers/cshared_test.go b/src/cmd/cgo/internal/testsanitizers/cshared_test.go index 0cf094ead79e66..fc30204262acfe 100644 --- a/src/cmd/cgo/internal/testsanitizers/cshared_test.go +++ b/src/cmd/cgo/internal/testsanitizers/cshared_test.go @@ -54,7 +54,6 @@ func TestShared(t *testing.T) { } for _, tc := range cases { - tc := tc name := strings.TrimSuffix(tc.src, ".go") //The memory sanitizer tests require support for the -msan option. if tc.sanitizer == "memory" && !platform.MSanSupported(GOOS, GOARCH) { diff --git a/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go b/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go index 9f548d66eace03..6749709ddd8d45 100644 --- a/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go +++ b/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go @@ -43,7 +43,6 @@ func TestLibFuzzer(t *testing.T) { {goSrc: "libfuzzer2.go", cSrc: "libfuzzer2.c", expectedError: "panic: found it"}, } for _, tc := range cases { - tc := tc name := strings.TrimSuffix(tc.goSrc, ".go") t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/src/cmd/cgo/internal/testsanitizers/msan_test.go b/src/cmd/cgo/internal/testsanitizers/msan_test.go index 554cceaff88669..811a1438397eb0 100644 --- a/src/cmd/cgo/internal/testsanitizers/msan_test.go +++ b/src/cmd/cgo/internal/testsanitizers/msan_test.go @@ -62,7 +62,6 @@ func TestMSAN(t *testing.T) { {src: "arena_fail.go", wantErr: true, experiments: []string{"arenas"}}, } for _, tc := range cases { - tc := tc name := strings.TrimSuffix(tc.src, ".go") t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/src/cmd/cgo/internal/testsanitizers/tsan_test.go b/src/cmd/cgo/internal/testsanitizers/tsan_test.go index 589db2e6bc4e34..81fc00900f9e37 100644 --- a/src/cmd/cgo/internal/testsanitizers/tsan_test.go +++ b/src/cmd/cgo/internal/testsanitizers/tsan_test.go @@ -59,7 +59,6 @@ func TestTSAN(t *testing.T) { {src: "tsan_tracebackctxt", needsRuntime: true}, // Subdirectory } for _, tc := range cases { - tc := tc name := strings.TrimSuffix(tc.src, ".go") t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/src/cmd/cgo/internal/teststdio/stdio_test.go b/src/cmd/cgo/internal/teststdio/stdio_test.go index 9150281ae87ff3..f9e7fe507989f4 100644 --- a/src/cmd/cgo/internal/teststdio/stdio_test.go +++ b/src/cmd/cgo/internal/teststdio/stdio_test.go @@ -56,7 +56,6 @@ func TestTestRun(t *testing.T) { "fib.go", "hello.go", } { - file := file wantFile := strings.Replace(file, ".go", ".out", 1) t.Run(file, func(t *testing.T) { cmd := exec.Command(testenv.GoToolPath(t), "run", file) diff --git a/src/cmd/compile/internal/test/reproduciblebuilds_test.go b/src/cmd/compile/internal/test/reproduciblebuilds_test.go index 466e0c3a38ae1b..b2ff4068a8a86a 100644 --- a/src/cmd/compile/internal/test/reproduciblebuilds_test.go +++ b/src/cmd/compile/internal/test/reproduciblebuilds_test.go @@ -26,7 +26,6 @@ func TestReproducibleBuilds(t *testing.T) { } t.Parallel() for _, test := range tests { - test := test t.Run(test, func(t *testing.T) { t.Parallel() var want []byte diff --git a/src/cmd/compile/internal/test/ssa_test.go b/src/cmd/compile/internal/test/ssa_test.go index 7d213fcecac458..10f32f65ad9fd9 100644 --- a/src/cmd/compile/internal/test/ssa_test.go +++ b/src/cmd/compile/internal/test/ssa_test.go @@ -163,7 +163,6 @@ func TestCode(t *testing.T) { // Now we have a test binary. Run it with all the tests as subtests of this one. for _, test := range tests { - test := test if flag == ",softfloat" && !test.usesFloat { // No point in running the soft float version if the test doesn't use floats. continue diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index 4b7012e6c45e9f..376fc46fb235f6 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -2420,7 +2420,6 @@ type K = Nested[string] ) var wg sync.WaitGroup for i := 0; i < 2; i++ { - i := i wg.Add(1) go func() { defer wg.Done() @@ -2599,7 +2598,6 @@ func fn() { }) for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { if got := len(idents[test.name]); got != 1 { t.Fatalf("found %d identifiers named %s, want 1", got, test.name) diff --git a/src/cmd/compile/internal/types2/sizes_test.go b/src/cmd/compile/internal/types2/sizes_test.go index 9a772f4b1523fe..9597db58cb983d 100644 --- a/src/cmd/compile/internal/types2/sizes_test.go +++ b/src/cmd/compile/internal/types2/sizes_test.go @@ -184,7 +184,6 @@ func main() { func TestGCSizes(t *testing.T) { types2.DefPredeclaredTestFuncs() for _, tc := range gcSizesTests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() conf := types2.Config{Importer: defaultImporter(), Sizes: types2.SizesFor("gc", "amd64")} diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go index f778a01a7adb07..1ce7c53fe1e85d 100644 --- a/src/cmd/compile/internal/types2/stdlib_test.go +++ b/src/cmd/compile/internal/types2/stdlib_test.go @@ -59,7 +59,6 @@ func TestStdlib(t *testing.T) { var wg sync.WaitGroup for dir := range dirFiles { - dir := dir cpulimit <- struct{}{} wg.Add(1) diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 1722f1a2c34428..875844802acafc 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1545,7 +1545,6 @@ func TestListTemplateContextFunction(t *testing.T) { {"ReleaseTags", ""}, {"InstallSuffix", ""}, } { - tt := tt t.Run(tt.v, func(t *testing.T) { tg := testgo(t) tg.parallel() diff --git a/src/cmd/go/internal/modfetch/coderepo_test.go b/src/cmd/go/internal/modfetch/coderepo_test.go index 68594746601a22..d8d7580fd4af44 100644 --- a/src/cmd/go/internal/modfetch/coderepo_test.go +++ b/src/cmd/go/internal/modfetch/coderepo_test.go @@ -819,7 +819,6 @@ func TestCodeRepoVersions(t *testing.T) { testenv.MustHaveExternalNetwork(t) for _, tt := range codeRepoVersionsTests { - tt := tt t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) { if strings.Contains(tt.path, "gopkg.in") { testenv.SkipFlaky(t, 54503) @@ -902,7 +901,6 @@ func TestLatest(t *testing.T) { for _, tt := range latestTests { name := strings.ReplaceAll(tt.path, "/", "_") t.Run(name, func(t *testing.T) { - tt := tt t.Parallel() if tt.vcs != "mod" { testenv.MustHaveExecPath(t, tt.vcs) diff --git a/src/cmd/go/internal/modload/query_test.go b/src/cmd/go/internal/modload/query_test.go index a465fab5db3933..e435c95b816192 100644 --- a/src/cmd/go/internal/modload/query_test.go +++ b/src/cmd/go/internal/modload/query_test.go @@ -179,7 +179,6 @@ func TestQuery(t *testing.T) { } return nil } - tt := tt t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.query+"/"+tt.current+"/"+allow, func(t *testing.T) { t.Parallel() diff --git a/src/cmd/go/internal/web/url_test.go b/src/cmd/go/internal/web/url_test.go index 8f462f53259b5c..5e7a2a882ebb41 100644 --- a/src/cmd/go/internal/web/url_test.go +++ b/src/cmd/go/internal/web/url_test.go @@ -14,7 +14,6 @@ func TestURLToFilePath(t *testing.T) { if tc.url == "" { continue } - tc := tc t.Run(tc.url, func(t *testing.T) { u, err := url.Parse(tc.url) @@ -46,7 +45,6 @@ func TestURLFromFilePath(t *testing.T) { if tc.filePath == "" { continue } - tc := tc t.Run(tc.filePath, func(t *testing.T) { u, err := urlFromFilePath(tc.filePath) diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index 390a36723787f4..f6eaddf8fb3f40 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -107,7 +107,6 @@ func TestScript(t *testing.T) { t.Fatal(err) } for _, file := range files { - file := file name := strings.TrimSuffix(filepath.Base(file), ".txt") t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/src/cmd/internal/par/queue_test.go b/src/cmd/internal/par/queue_test.go index 1331e65f98a81f..4d2bcf09febf62 100644 --- a/src/cmd/internal/par/queue_test.go +++ b/src/cmd/internal/par/queue_test.go @@ -51,7 +51,6 @@ func TestQueueBacklog(t *testing.T) { unblock := make(chan struct{}) for i := range started { started[i] = make(chan struct{}) - i := i q.Add(func() { close(started[i]) <-unblock diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go index 56a076002a92d4..291d67f2b770e4 100644 --- a/src/cmd/link/dwarf_test.go +++ b/src/cmd/link/dwarf_test.go @@ -82,7 +82,6 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string) t.Parallel() for _, prog := range []string{"testprog", "testprogcgo"} { - prog := prog expectDWARF := expectDWARF if runtime.GOOS == "aix" && prog == "testprogcgo" { extld := os.Getenv("CC") diff --git a/src/cmd/link/internal/ld/deadcode_test.go b/src/cmd/link/internal/ld/deadcode_test.go index 6962a4eba01195..95de54d54adc98 100644 --- a/src/cmd/link/internal/ld/deadcode_test.go +++ b/src/cmd/link/internal/ld/deadcode_test.go @@ -34,7 +34,6 @@ func TestDeadcode(t *testing.T) { []string{"main.large"}}, } for _, test := range tests { - test := test t.Run(test.src, func(t *testing.T) { t.Parallel() src := filepath.Join("testdata", "deadcode", test.src+".go") diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go index cc493f2c699814..7d76a06250a4d4 100644 --- a/src/cmd/link/internal/ld/dwarf_test.go +++ b/src/cmd/link/internal/ld/dwarf_test.go @@ -408,7 +408,6 @@ func main() {} }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -473,7 +472,6 @@ func main() { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -555,7 +553,6 @@ func main() { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -1980,7 +1977,6 @@ func TestZeroSizedVariable(t *testing.T) { // See go.dev/issues/54615. for _, opt := range []string{NoOpt, DefaultOpt} { - opt := opt t.Run(opt, func(t *testing.T) { _, ex := gobuildAndExamine(t, zeroSizedVarProg, opt) diff --git a/src/cmd/link/internal/ld/ld_test.go b/src/cmd/link/internal/ld/ld_test.go index 64b86f3a0b1153..d6f76347475d40 100644 --- a/src/cmd/link/internal/ld/ld_test.go +++ b/src/cmd/link/internal/ld/ld_test.go @@ -354,7 +354,6 @@ func main() { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() tempDir := t.TempDir() diff --git a/src/cmd/link/link_test.go b/src/cmd/link/link_test.go index 6ab1246c814dfb..e122e102766768 100644 --- a/src/cmd/link/link_test.go +++ b/src/cmd/link/link_test.go @@ -1622,7 +1622,6 @@ func TestCheckLinkname(t *testing.T) { {"badlinkname.go", true}, } for _, test := range tests { - test := test t.Run(test.src, func(t *testing.T) { t.Parallel() src := "./testdata/linkname/" + test.src diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go index 3e7bddc791154c..c680fd1308c06a 100644 --- a/src/os/os_windows_test.go +++ b/src/os/os_windows_test.go @@ -1234,7 +1234,6 @@ func TestReadlink(t *testing.T) { {junction: false, dir: false, drive: false, relative: true}, } for _, tt := range tests { - tt := tt var name string if tt.junction { name = "junction" diff --git a/src/runtime/panic_test.go b/src/runtime/panic_test.go index 2b06bce45d260e..8ffe9383e9fca3 100644 --- a/src/runtime/panic_test.go +++ b/src/runtime/panic_test.go @@ -39,7 +39,6 @@ func TestPanicWithDirectlyPrintableCustomTypes(t *testing.T) { } for _, tt := range tests { - t := t t.Run(tt.name, func(t *testing.T) { output := runTestProg(t, "testprog", tt.name) if !strings.HasPrefix(output, tt.wantPanicPrefix) { diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go index 6a9b165d62422e..ce74883f1d98ac 100644 --- a/src/runtime/syscall_windows_test.go +++ b/src/runtime/syscall_windows_test.go @@ -778,7 +778,6 @@ func TestSyscallN(t *testing.T) { } for arglen := 0; arglen <= windows.MaxArgs; arglen++ { - arglen := arglen t.Run(fmt.Sprintf("arg-%d", arglen), func(t *testing.T) { t.Parallel() args := make([]string, arglen)