Skip to content

Commit b5aefe0

Browse files
tklausergopherbot
authored andcommitted
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 <lehner.florian86@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 5137c47 commit b5aefe0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+0
-99
lines changed

src/archive/zip/reader_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,6 @@ func TestFS(t *testing.T) {
12131213
[]string{"a/b/c"},
12141214
},
12151215
} {
1216-
test := test
12171216
t.Run(test.file, func(t *testing.T) {
12181217
t.Parallel()
12191218
z, err := OpenReader(test.file)
@@ -1247,7 +1246,6 @@ func TestFSWalk(t *testing.T) {
12471246
wantErr: true,
12481247
},
12491248
} {
1250-
test := test
12511249
t.Run(test.file, func(t *testing.T) {
12521250
t.Parallel()
12531251
z, err := OpenReader(test.file)

src/context/x_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,6 @@ func TestCause(t *testing.T) {
838838
cause: parentCause,
839839
},
840840
} {
841-
test := test
842841
t.Run(test.name, func(t *testing.T) {
843842
t.Parallel()
844843
ctx := test.ctx()

src/crypto/cipher/ctr_aes_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ func TestCTR_AES_multiblock_random_IV(t *testing.T) {
145145
const Size = 100
146146

147147
for _, keySize := range []int{16, 24, 32} {
148-
keySize := keySize
149148
t.Run(fmt.Sprintf("keySize=%d", keySize), func(t *testing.T) {
150149
key := randBytes(t, r, keySize)
151150
aesBlock, err := aes.NewCipher(key)
@@ -164,10 +163,8 @@ func TestCTR_AES_multiblock_random_IV(t *testing.T) {
164163
// individually using multiblock implementation to catch edge cases.
165164

166165
for part1 := 0; part1 <= Size; part1++ {
167-
part1 := part1
168166
t.Run(fmt.Sprintf("part1=%d", part1), func(t *testing.T) {
169167
for part2 := 0; part2 <= Size-part1; part2++ {
170-
part2 := part2
171168
t.Run(fmt.Sprintf("part2=%d", part2), func(t *testing.T) {
172169
_, multiblockCtr := makeTestingCiphers(aesBlock, iv)
173170
multiblockCiphertext := make([]byte, len(plaintext))
@@ -216,7 +213,6 @@ func TestCTR_AES_multiblock_overflow_IV(t *testing.T) {
216213
}
217214

218215
for _, keySize := range []int{16, 24, 32} {
219-
keySize := keySize
220216
t.Run(fmt.Sprintf("keySize=%d", keySize), func(t *testing.T) {
221217
for _, iv := range ivs {
222218
key := randBytes(t, r, keySize)
@@ -227,7 +223,6 @@ func TestCTR_AES_multiblock_overflow_IV(t *testing.T) {
227223

228224
t.Run(fmt.Sprintf("iv=%s", hex.EncodeToString(iv)), func(t *testing.T) {
229225
for _, offset := range []int{0, 1, 16, 1024} {
230-
offset := offset
231226
t.Run(fmt.Sprintf("offset=%d", offset), func(t *testing.T) {
232227
genericCtr, multiblockCtr := makeTestingCiphers(aesBlock, iv)
233228

@@ -260,7 +255,6 @@ func TestCTR_AES_multiblock_XORKeyStreamAt(t *testing.T) {
260255
plaintext := randBytes(t, r, Size)
261256

262257
for _, keySize := range []int{16, 24, 32} {
263-
keySize := keySize
264258
t.Run(fmt.Sprintf("keySize=%d", keySize), func(t *testing.T) {
265259
key := randBytes(t, r, keySize)
266260
iv := randBytes(t, r, aesBlockSize)

src/crypto/rsa/rsa_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ func TestEverything(t *testing.T) {
212212
max = 2048
213213
}
214214
for size := min; size <= max; size++ {
215-
size := size
216215
t.Run(fmt.Sprintf("%d", size), func(t *testing.T) {
217216
t.Parallel()
218217
priv, err := GenerateKey(rand.Reader, size)

src/crypto/tls/handshake_client_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2693,7 +2693,6 @@ func TestTLS13OnlyClientHelloCipherSuite(t *testing.T) {
26932693
},
26942694
}
26952695
for _, tt := range tls13Tests {
2696-
tt := tt
26972696
t.Run(tt.name, func(t *testing.T) {
26982697
t.Parallel()
26992698
testTLS13OnlyClientHelloCipherSuite(t, tt.ciphers)

src/crypto/tls/tls_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,6 @@ func testVerifyCertificates(t *testing.T, version uint16) {
18801880
rootCAs.AddCert(issuer)
18811881

18821882
for _, test := range tests {
1883-
test := test
18841883
t.Run(test.name, func(t *testing.T) {
18851884
t.Parallel()
18861885

src/crypto/x509/platform_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ func TestPlatformVerifier(t *testing.T) {
202202
}
203203

204204
for _, tc := range tests {
205-
tc := tc
206205
t.Run(tc.name, func(t *testing.T) {
207206
t.Parallel()
208207
parent := testRoot

src/database/sql/sql_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2939,7 +2939,6 @@ func TestConnExpiresFreshOutOfPool(t *testing.T) {
29392939
db.SetMaxOpenConns(1)
29402940

29412941
for _, ec := range execCases {
2942-
ec := ec
29432942
name := fmt.Sprintf("expired=%t,badReset=%t", ec.expired, ec.badReset)
29442943
t.Run(name, func(t *testing.T) {
29452944
db.clearAllConns(t)

src/debug/buildinfo/buildinfo_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,13 @@ func TestReadFile(t *testing.T) {
238238
}
239239

240240
for _, p := range platforms {
241-
p := p
242241
t.Run(p.goos+"_"+p.goarch, func(t *testing.T) {
243242
if p != runtimePlatform && !*flagAll {
244243
t.Skipf("skipping platforms other than %s_%s because -all was not set", runtimePlatform.goos, runtimePlatform.goarch)
245244
}
246245
for _, mode := range buildModes {
247-
mode := mode
248246
t.Run(mode, func(t *testing.T) {
249247
for _, tc := range cases {
250-
tc := tc
251248
t.Run(tc.name, func(t *testing.T) {
252249
t.Parallel()
253250
name := tc.build(t, p.goos, p.goarch, mode)

src/debug/elf/file_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,6 @@ var relocationTests = []relocationTest{
10401040

10411041
func TestDWARFRelocations(t *testing.T) {
10421042
for _, test := range relocationTests {
1043-
test := test
10441043
t.Run(test.file, func(t *testing.T) {
10451044
t.Parallel()
10461045
f, err := Open(test.file)

0 commit comments

Comments
 (0)