Skip to content

Commit d25c6f0

Browse files
authored
all: not copy loop var for golang v1.22 (XinFinOrg#1020)
1 parent d955e17 commit d25c6f0

File tree

12 files changed

+0
-14
lines changed

12 files changed

+0
-14
lines changed

eth/downloader/downloader.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ func (d *Downloader) spawnSync(fetchers []func() error) error {
489489
errc := make(chan error, len(fetchers))
490490
d.cancelWg.Add(len(fetchers))
491491
for _, fn := range fetchers {
492-
fn := fn
493492
go func() { defer d.cancelWg.Done(); errc <- fn() }()
494493
}
495494
// Wait for the first error, then terminate the others.

eth/handler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
166166
continue
167167
}
168168
// Compatible; initialise the sub-protocol
169-
version := version // Closure for the run
170169
manager.SubProtocols = append(manager.SubProtocols, p2p.Protocol{
171170
Name: ProtocolName,
172171
Version: version,

eth/tracers/testing/calltrace_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
7575
if !strings.HasSuffix(file.Name(), ".json") {
7676
continue
7777
}
78-
file := file // capture range variable
7978
t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) {
8079
t.Parallel()
8180

@@ -180,7 +179,6 @@ func BenchmarkTracers(b *testing.B) {
180179
if !strings.HasSuffix(file.Name(), ".json") {
181180
continue
182181
}
183-
file := file // capture range variable
184182
b.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(b *testing.B) {
185183
blob, err := os.ReadFile(filepath.Join("..", "testdata", "call_tracer", file.Name()))
186184
if err != nil {
@@ -259,7 +257,6 @@ func testContractTracer(tracerName string, dirPath string, t *testing.T) {
259257
if !strings.HasSuffix(file.Name(), ".json") {
260258
continue
261259
}
262-
file := file // capture range variable
263260
t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) {
264261
t.Parallel()
265262

node/api_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ func TestStartRPC(t *testing.T) {
244244
}
245245

246246
for _, test := range tests {
247-
test := test
248247
t.Run(test.name, func(t *testing.T) {
249248
t.Parallel()
250249

node/node_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ func TestNodeRPCPrefix(t *testing.T) {
475475
}
476476

477477
for _, test := range tests {
478-
test := test
479478
name := fmt.Sprintf("http=%s ws=%s", test.httpPrefix, test.wsPrefix)
480479
t.Run(name, func(t *testing.T) {
481480
cfg := &Config{

node/rpcstack_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ func TestGzipHandler(t *testing.T) {
507507
}
508508

509509
for _, test := range tests {
510-
test := test
511510
t.Run(test.name, func(t *testing.T) {
512511
srv := httptest.NewServer(newGzipHandler(test.handler))
513512
defer srv.Close()

p2p/peer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ outer:
355355
func (p *Peer) startProtocols(writeStart <-chan struct{}, writeErr chan<- error) {
356356
p.wg.Add(len(p.running))
357357
for _, proto := range p.running {
358-
proto := proto
359358
proto.closed = p.closed
360359
proto.wstart = writeStart
361360
proto.werr = writeErr

rlp/decode_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ func TestStreamReadBytes(t *testing.T) {
308308
}
309309

310310
for _, test := range tests {
311-
test := test
312311
name := fmt.Sprintf("input_%s/size_%d", test.input, test.size)
313312
t.Run(name, func(t *testing.T) {
314313
s := NewStream(bytes.NewReader(unhex(test.input)), 0)

rlp/rlpgen/gen_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ var tests = []string{"uints", "nil", "rawvalue", "optional", "bigint", "uint256"
5151

5252
func TestOutput(t *testing.T) {
5353
for _, test := range tests {
54-
test := test
5554
t.Run(test, func(t *testing.T) {
5655
inputFile := filepath.Join("testdata", test+".in.txt")
5756
outputFile := filepath.Join("testdata", test+".out.txt")

rpc/client_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,6 @@ func TestClientHTTP(t *testing.T) {
776776
wantResult = echoResult{"a", 1, new(echoArgs)}
777777
)
778778
for i := range results {
779-
i := i
780779
go func() {
781780
errc <- client.Call(&results[i], "test_echo", wantResult.String, wantResult.Int, wantResult.Args)
782781
}()

rpc/types_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ func TestBlockNumberOrHash_WithNumber_MarshalAndUnmarshal(t *testing.T) {
143143
{"finalized", int64(CommittedBlockNumber)},
144144
}
145145
for _, test := range tests {
146-
test := test
147146
t.Run(test.name, func(t *testing.T) {
148147
bnh := BlockNumberOrHashWithNumber(BlockNumber(test.number))
149148
marshalled, err := json.Marshal(bnh)

tests/state_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func TestState(t *testing.T) {
5454

5555
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
5656
for _, subtest := range test.Subtests() {
57-
subtest := subtest
5857
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
5958
name := name + "/" + key
6059
t.Run(key, func(t *testing.T) {

0 commit comments

Comments
 (0)