Skip to content

Commit d2240e6

Browse files
committed
all: remove unneeded loop variables in tests
GOMOD=off modernize -forvar -fix -test ./... Fixes #76411.
1 parent d30884b commit d2240e6

File tree

36 files changed

+43
-48
lines changed

36 files changed

+43
-48
lines changed

src/cmd/api/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ var warmupCache = sync.OnceFunc(func() {
232232
// Warm up the import cache in parallel.
233233
var wg sync.WaitGroup
234234
for _, context := range contexts {
235-
context := context
235+
236236
wg.Add(1)
237237
go func() {
238238
defer wg.Done()

src/cmd/api/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func Check(t *testing.T) {
121121
walkers := make([]*Walker, len(contexts))
122122
var wg sync.WaitGroup
123123
for i, context := range contexts {
124-
i, context := i, context
124+
125125
wg.Add(1)
126126
go func() {
127127
defer wg.Done()

src/cmd/cgo/internal/testerrors/errors_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func TestToleratesOptimizationFlag(t *testing.T) {
152152
"",
153153
"-O",
154154
} {
155-
cflags := cflags
155+
156156
t.Run(cflags, func(t *testing.T) {
157157
testenv.MustHaveGoBuild(t)
158158
testenv.MustHaveCGO(t)

src/cmd/cgo/internal/testsanitizers/asan_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestASAN(t *testing.T) {
4848
{src: "arena_fail.go", memoryAccessError: "use-after-poison", errorLocation: "arena_fail.go:26", experiments: []string{"arenas"}},
4949
}
5050
for _, tc := range cases {
51-
tc := tc
51+
5252
name := strings.TrimSuffix(tc.src, ".go")
5353
t.Run(name, func(t *testing.T) {
5454
t.Parallel()

src/cmd/cgo/internal/testsanitizers/cshared_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestShared(t *testing.T) {
5454
}
5555

5656
for _, tc := range cases {
57-
tc := tc
57+
5858
name := strings.TrimSuffix(tc.src, ".go")
5959
//The memory sanitizer tests require support for the -msan option.
6060
if tc.sanitizer == "memory" && !platform.MSanSupported(GOOS, GOARCH) {

src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestLibFuzzer(t *testing.T) {
4343
{goSrc: "libfuzzer2.go", cSrc: "libfuzzer2.c", expectedError: "panic: found it"},
4444
}
4545
for _, tc := range cases {
46-
tc := tc
46+
4747
name := strings.TrimSuffix(tc.goSrc, ".go")
4848
t.Run(name, func(t *testing.T) {
4949
t.Parallel()

src/cmd/cgo/internal/testsanitizers/msan_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestMSAN(t *testing.T) {
6262
{src: "arena_fail.go", wantErr: true, experiments: []string{"arenas"}},
6363
}
6464
for _, tc := range cases {
65-
tc := tc
65+
6666
name := strings.TrimSuffix(tc.src, ".go")
6767
t.Run(name, func(t *testing.T) {
6868
t.Parallel()

src/cmd/cgo/internal/testsanitizers/tsan_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestTSAN(t *testing.T) {
5959
{src: "tsan_tracebackctxt", needsRuntime: true}, // Subdirectory
6060
}
6161
for _, tc := range cases {
62-
tc := tc
62+
6363
name := strings.TrimSuffix(tc.src, ".go")
6464
t.Run(name, func(t *testing.T) {
6565
t.Parallel()

src/cmd/cgo/internal/teststdio/stdio_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestTestRun(t *testing.T) {
5656
"fib.go",
5757
"hello.go",
5858
} {
59-
file := file
59+
6060
wantFile := strings.Replace(file, ".go", ".out", 1)
6161
t.Run(file, func(t *testing.T) {
6262
cmd := exec.Command(testenv.GoToolPath(t), "run", file)

src/cmd/compile/internal/gc/compile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func compileFunctions(profile *pgoir.Profile) {
194194
compile = func(fns []*ir.Func) {
195195
wg.Add(len(fns))
196196
for _, fn := range fns {
197-
fn := fn
197+
198198
queue(func(worker int) {
199199
ssagen.Compile(fn, worker, profile)
200200
compile(fn.Closures)

0 commit comments

Comments
 (0)