Browse code

modernize: Use range int

Added in Go 1.22

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Paweł Gronowski authored on 2025/12/16 02:26:55
Showing 59 changed files
... ...
@@ -628,7 +628,7 @@ func parsePortSpec(rawPort string) ([]network.PortMap, error) {
628 628
 	count := endPort - startPort + 1
629 629
 	ports := make([]network.PortMap, 0, count)
630 630
 
631
-	for i := uint16(0); i < count; i++ {
631
+	for i := range count {
632 632
 		hPort := ""
633 633
 		if hostPort != "" {
634 634
 			hPort = strconv.Itoa(int(startHostPort + i))
... ...
@@ -302,7 +302,7 @@ func TestTarSumsReadSize(t *testing.T) {
302 302
 	// Test always on the same layer (that is big enough)
303 303
 	layer := testLayers[0]
304 304
 
305
-	for i := 0; i < 5; i++ {
305
+	for i := range 5 {
306 306
 		reader, err := os.Open(layer.filename)
307 307
 		if err != nil {
308 308
 			t.Fatal(err)
... ...
@@ -296,7 +296,7 @@ func TestOtelMeterLeak(t *testing.T) {
296 296
 	runtime.ReadMemStats(&before)
297 297
 
298 298
 	const counters = 10 * 1000 * 1000
299
-	for i := 0; i < counters; i++ {
299
+	for range counters {
300 300
 		_, _ = meter.Int64Counter("bar")
301 301
 	}
302 302
 
... ...
@@ -41,7 +41,7 @@ func benchmarkReplaceOrAppendEnvValues(b *testing.B, extraEnv int) {
41 41
 
42 42
 	if extraEnv > 0 {
43 43
 		buf := make([]byte, 5)
44
-		for i := 0; i < extraEnv; i++ {
44
+		for range extraEnv {
45 45
 			n, err := rand.Read(buf)
46 46
 			assert.NilError(b, err)
47 47
 			key := string(buf[:n])
... ...
@@ -347,7 +347,7 @@ func assertIndexGet(t *testing.T, snapshot *ViewDB, input, expectedResult string
347 347
 
348 348
 func BenchmarkDBAdd100(b *testing.B) {
349 349
 	var testSet []string
350
-	for i := 0; i < 100; i++ {
350
+	for range 100 {
351 351
 		testSet = append(testSet, stringid.GenerateRandomID())
352 352
 	}
353 353
 
... ...
@@ -367,7 +367,7 @@ func BenchmarkDBAdd100(b *testing.B) {
367 367
 func BenchmarkDBGetByPrefix100(b *testing.B) {
368 368
 	var testSet []string
369 369
 	var testKeys []string
370
-	for i := 0; i < 100; i++ {
370
+	for range 100 {
371 371
 		testSet = append(testSet, stringid.GenerateRandomID())
372 372
 	}
373 373
 	db, err := NewViewDB()
... ...
@@ -394,7 +394,7 @@ func BenchmarkDBGetByPrefix100(b *testing.B) {
394 394
 func BenchmarkDBGetByPrefix250(b *testing.B) {
395 395
 	var testSet []string
396 396
 	var testKeys []string
397
-	for i := 0; i < 250; i++ {
397
+	for range 250 {
398 398
 		testSet = append(testSet, stringid.GenerateRandomID())
399 399
 	}
400 400
 	db, err := NewViewDB()
... ...
@@ -421,7 +421,7 @@ func BenchmarkDBGetByPrefix250(b *testing.B) {
421 421
 func BenchmarkDBGetByPrefix500(b *testing.B) {
422 422
 	var testSet []string
423 423
 	var testKeys []string
424
-	for i := 0; i < 500; i++ {
424
+	for range 500 {
425 425
 		testSet = append(testSet, stringid.GenerateRandomID())
426 426
 	}
427 427
 	db, err := NewViewDB()
... ...
@@ -49,7 +49,7 @@ func BenchmarkImageList(b *testing.B) {
49 49
 		// Use constant seed for reproducibility
50 50
 		src := rand.NewSource(1982731263716)
51 51
 
52
-		for i := 0; i < count; i++ {
52
+		for i := range count {
53 53
 			platform := platforms.DefaultSpec()
54 54
 
55 55
 			// 20% is other architecture than the host
... ...
@@ -73,7 +73,7 @@ func BenchmarkImageList(b *testing.B) {
73 73
 				}
74 74
 
75 75
 				containersCount := r2 % maxContainerCount
76
-				for j := 0; j < containersCount; j++ {
76
+				for range containersCount {
77 77
 					id := digest.FromString(desc.Name + strconv.Itoa(i)).String()
78 78
 
79 79
 					target := desc.Target
... ...
@@ -74,7 +74,7 @@ func TestEventsLogTimeout(t *testing.T) {
74 74
 func TestLogEvents(t *testing.T) {
75 75
 	e := New()
76 76
 
77
-	for i := 0; i < eventsLimit+16; i++ {
77
+	for i := range eventsLimit + 16 {
78 78
 		num := strconv.Itoa(i)
79 79
 		e.Log(events.Action("action_"+num), events.ContainerEventType, events.Actor{
80 80
 			ID:         "cont_" + num,
... ...
@@ -83,7 +83,7 @@ func TestLogEvents(t *testing.T) {
83 83
 	}
84 84
 	time.Sleep(50 * time.Millisecond)
85 85
 	current, l, _ := e.Subscribe()
86
-	for i := 0; i < 10; i++ {
86
+	for i := range 10 {
87 87
 		num := strconv.Itoa(i + eventsLimit + 16)
88 88
 		e.Log(events.Action("action_"+num), events.ContainerEventType, events.Actor{
89 89
 			ID:         "cont_" + num,
... ...
@@ -77,7 +77,7 @@ func TestCopyDir(t *testing.T) {
77 77
 }
78 78
 
79 79
 func randomMode(baseMode int) os.FileMode {
80
-	for i := 0; i < 7; i++ {
80
+	for i := range 7 {
81 81
 		baseMode = baseMode | (1&rand.Intn(2))<<uint(i)
82 82
 	}
83 83
 	return os.FileMode(baseMode)
... ...
@@ -90,7 +90,7 @@ func populateSrcDir(t *testing.T, srcDir string, remainingDepth int) {
90 90
 	aTime := time.Unix(rand.Int63(), 0)
91 91
 	mTime := time.Unix(rand.Int63(), 0)
92 92
 
93
-	for i := 0; i < 10; i++ {
93
+	for i := range 10 {
94 94
 		dirName := filepath.Join(srcDir, fmt.Sprintf("srcdir-%d", i))
95 95
 		// Owner all bits set
96 96
 		assert.NilError(t, os.Mkdir(dirName, randomMode(0o700)))
... ...
@@ -98,7 +98,7 @@ func populateSrcDir(t *testing.T, srcDir string, remainingDepth int) {
98 98
 		assert.NilError(t, system.Chtimes(dirName, aTime, mTime))
99 99
 	}
100 100
 
101
-	for i := 0; i < 10; i++ {
101
+	for i := range 10 {
102 102
 		fileName := filepath.Join(srcDir, fmt.Sprintf("srcfile-%d", i))
103 103
 		// Owner read bit set
104 104
 		assert.NilError(t, os.WriteFile(fileName, []byte{}, randomMode(0o400)))
... ...
@@ -97,7 +97,7 @@ func TestV2MetadataService(t *testing.T) {
97 97
 
98 98
 func randomDigest() digest.Digest {
99 99
 	b := [32]byte{}
100
-	for i := 0; i < len(b); i++ {
100
+	for i := range len(b) {
101 101
 		b[i] = byte(rand.Intn(256))
102 102
 	}
103 103
 	d := hex.EncodeToString(b[:])
... ...
@@ -193,7 +193,7 @@ func BenchmarkBytesPipeWrite(b *testing.B) {
193 193
 				_, err = buf.Read(readBuf)
194 194
 			}
195 195
 		}()
196
-		for j := 0; j < 1000; j++ {
196
+		for range 1000 {
197 197
 			_, _ = buf.Write(testData)
198 198
 		}
199 199
 		_ = buf.Close()
... ...
@@ -206,11 +206,11 @@ func BenchmarkBytesPipeRead(b *testing.B) {
206 206
 	for b.Loop() {
207 207
 		b.StopTimer()
208 208
 		buf := New()
209
-		for j := 0; j < 500; j++ {
209
+		for range 500 {
210 210
 			_, _ = buf.Write(make([]byte, 1024))
211 211
 		}
212 212
 		b.StartTimer()
213
-		for j := 0; j < 1000; j++ {
213
+		for range 1000 {
214 214
 			if n, _ := buf.Read(rd); n != 512 {
215 215
 				b.Fatalf("Wrong number of bytes: %d", n)
216 216
 			}
... ...
@@ -130,7 +130,7 @@ func TestRaceUnbuffered(t *testing.T) {
130 130
 func BenchmarkUnbuffered(b *testing.B) {
131 131
 	writer := new(unbuffered)
132 132
 	setUpWriter := func() {
133
-		for i := 0; i < 100; i++ {
133
+		for range 100 {
134 134
 			writer.Add(devNullCloser(0))
135 135
 			writer.Add(devNullCloser(0))
136 136
 			writer.Add(devNullCloser(0))
... ...
@@ -138,7 +138,7 @@ func BenchmarkUnbuffered(b *testing.B) {
138 138
 	}
139 139
 	testLine := "Line that thinks that it is log line from docker"
140 140
 	var buf bytes.Buffer
141
-	for i := 0; i < 100; i++ {
141
+	for range 100 {
142 142
 		buf.WriteString(testLine + "\n")
143 143
 	}
144 144
 	// line without eol
... ...
@@ -151,7 +151,7 @@ func BenchmarkUnbuffered(b *testing.B) {
151 151
 		setUpWriter()
152 152
 		b.StartTimer()
153 153
 
154
-		for j := 0; j < 5; j++ {
154
+		for range 5 {
155 155
 			if _, err := writer.Write(testText); err != nil {
156 156
 				b.Fatal(err)
157 157
 			}
... ...
@@ -17,7 +17,7 @@ func compare(v1, v2 string) int {
17 17
 	)
18 18
 
19 19
 	maxVer := max(len(otherTab), len(currTab))
20
-	for i := 0; i < maxVer; i++ {
20
+	for i := range maxVer {
21 21
 		var currInt, otherInt int
22 22
 
23 23
 		if len(currTab) > i {
... ...
@@ -923,7 +923,7 @@ func TestMethods(t *testing.T) {
923 923
 		t.Fatalf("Unexpected sequence string: %s", hnd.head.toString())
924 924
 	}
925 925
 
926
-	for i := 0; i < 192; i++ {
926
+	for range 192 {
927 927
 		_, err := hnd.SetAny(false)
928 928
 		if err != nil {
929 929
 			t.Fatal(err)
... ...
@@ -1185,7 +1185,7 @@ func TestMarshalJSON(t *testing.T) {
1185 1185
 	hnd := New(uint64(len(expected) * 8))
1186 1186
 
1187 1187
 	for i, c := range expected {
1188
-		for j := 0; j < 8; j++ {
1188
+		for j := range 8 {
1189 1189
 			if c&(1<<j) == 0 {
1190 1190
 				continue
1191 1191
 			}
... ...
@@ -283,7 +283,7 @@ func checkTable(ctx context.Context, ips []string, port, networkName, tableName
283 283
 func waitWriters(parallelWriters int, mustWrite bool, doneCh chan resultTuple) map[string]int {
284 284
 	var totalKeys int
285 285
 	resultTable := make(map[string]int)
286
-	for i := 0; i < parallelWriters; i++ {
286
+	for i := range parallelWriters {
287 287
 		log.G(context.TODO()).Infof("Waiting for %d workers", parallelWriters-i)
288 288
 		workerReturn := <-doneCh
289 289
 		totalKeys += workerReturn.result
... ...
@@ -337,7 +337,7 @@ func doClusterPeers(ips []string, args []string) {
337 337
 	doneCh := make(chan resultTuple, len(ips))
338 338
 	expectedPeers, _ := strconv.Atoi(args[0])
339 339
 	maxRetry, _ := strconv.Atoi(args[1])
340
-	for retry := 0; retry < maxRetry; retry++ {
340
+	for retry := range maxRetry {
341 341
 		// check all the nodes
342 342
 		for _, ip := range ips {
343 343
 			go clusterPeersNumber(ip, servicePort, doneCh)
... ...
@@ -398,7 +398,7 @@ func doNetworkPeers(ips []string, args []string) {
398 398
 	networkName := args[0]
399 399
 	expectedPeers, _ := strconv.Atoi(args[1])
400 400
 	maxRetry, _ := strconv.Atoi(args[2])
401
-	for retry := 0; retry < maxRetry; retry++ {
401
+	for retry := range maxRetry {
402 402
 		// check all the nodes
403 403
 		for _, ip := range ips {
404 404
 			go networkPeersNumber(ip, servicePort, networkName, doneCh)
... ...
@@ -469,14 +469,14 @@ func doWriteKeys(ips []string, args []string) {
469 469
 
470 470
 	doneCh := make(chan resultTuple, parallelWriters)
471 471
 	// Enable watch of tables from clients
472
-	for i := 0; i < parallelWriters; i++ {
472
+	for i := range parallelWriters {
473 473
 		go clientWatchTable(ips[i], servicePort, networkName, tableName, doneCh)
474 474
 	}
475 475
 	waitWriters(parallelWriters, false, doneCh)
476 476
 
477 477
 	// Start parallel writers that will create and delete unique keys
478 478
 	defer close(doneCh)
479
-	for i := 0; i < parallelWriters; i++ {
479
+	for i := range parallelWriters {
480 480
 		key := "key-" + strconv.Itoa(i) + "-"
481 481
 		log.G(context.TODO()).Infof("Spawn worker: %d on IP:%s", i, ips[i])
482 482
 		go writeKeysNumber(ips[i], servicePort, networkName, tableName, key, numberOfKeys, doneCh)
... ...
@@ -502,14 +502,14 @@ func doDeleteKeys(ips []string, args []string) {
502 502
 
503 503
 	doneCh := make(chan resultTuple, parallelWriters)
504 504
 	// Enable watch of tables from clients
505
-	for i := 0; i < parallelWriters; i++ {
505
+	for i := range parallelWriters {
506 506
 		go clientWatchTable(ips[i], servicePort, networkName, tableName, doneCh)
507 507
 	}
508 508
 	waitWriters(parallelWriters, false, doneCh)
509 509
 
510 510
 	// Start parallel writers that will create and delete unique keys
511 511
 	defer close(doneCh)
512
-	for i := 0; i < parallelWriters; i++ {
512
+	for i := range parallelWriters {
513 513
 		key := "key-" + strconv.Itoa(i) + "-"
514 514
 		log.G(context.TODO()).Infof("Spawn worker: %d on IP:%s", i, ips[i])
515 515
 		go deleteKeysNumber(ips[i], servicePort, networkName, tableName, key, numberOfKeys, doneCh)
... ...
@@ -535,14 +535,14 @@ func doWriteDeleteUniqueKeys(ips []string, args []string) {
535 535
 
536 536
 	doneCh := make(chan resultTuple, parallelWriters)
537 537
 	// Enable watch of tables from clients
538
-	for i := 0; i < parallelWriters; i++ {
538
+	for i := range parallelWriters {
539 539
 		go clientWatchTable(ips[i], servicePort, networkName, tableName, doneCh)
540 540
 	}
541 541
 	waitWriters(parallelWriters, false, doneCh)
542 542
 
543 543
 	// Start parallel writers that will create and delete unique keys
544 544
 	ctx, cancel := context.WithTimeout(context.Background(), time.Duration(writeTimeSec)*time.Second)
545
-	for i := 0; i < parallelWriters; i++ {
545
+	for i := range parallelWriters {
546 546
 		key := "key-" + strconv.Itoa(i) + "-"
547 547
 		log.G(ctx).Infof("Spawn worker: %d on IP:%s", i, ips[i])
548 548
 		go writeDeleteUniqueKeys(ctx, ips[i], servicePort, networkName, tableName, key, doneCh)
... ...
@@ -572,7 +572,7 @@ func doWriteUniqueKeys(ips []string, args []string) {
572 572
 
573 573
 	doneCh := make(chan resultTuple, parallelWriters)
574 574
 	// Enable watch of tables from clients
575
-	for i := 0; i < parallelWriters; i++ {
575
+	for i := range parallelWriters {
576 576
 		go clientWatchTable(ips[i], servicePort, networkName, tableName, doneCh)
577 577
 	}
578 578
 	waitWriters(parallelWriters, false, doneCh)
... ...
@@ -580,7 +580,7 @@ func doWriteUniqueKeys(ips []string, args []string) {
580 580
 	// Start parallel writers that will create and delete unique keys
581 581
 	defer close(doneCh)
582 582
 	ctx, cancel := context.WithTimeout(context.Background(), time.Duration(writeTimeSec)*time.Second)
583
-	for i := 0; i < parallelWriters; i++ {
583
+	for i := range parallelWriters {
584 584
 		key := "key-" + strconv.Itoa(i) + "-"
585 585
 		log.G(ctx).Infof("Spawn worker: %d on IP:%s", i, ips[i])
586 586
 		go writeUniqueKeys(ctx, ips[i], servicePort, networkName, tableName, key, doneCh)
... ...
@@ -609,7 +609,7 @@ func doWriteDeleteLeaveJoin(ips []string, args []string) {
609 609
 	doneCh := make(chan resultTuple, parallelWriters)
610 610
 	defer close(doneCh)
611 611
 	ctx, cancel := context.WithTimeout(context.Background(), time.Duration(writeTimeSec)*time.Second)
612
-	for i := 0; i < parallelWriters; i++ {
612
+	for i := range parallelWriters {
613 613
 		key := "key-" + strconv.Itoa(i) + "-"
614 614
 		log.G(ctx).Infof("Spawn worker: %d on IP:%s", i, ips[i])
615 615
 		go writeDeleteLeaveJoin(ctx, ips[i], servicePort, networkName, tableName, key, doneCh)
... ...
@@ -638,7 +638,7 @@ func doWriteDeleteWaitLeaveJoin(ips []string, args []string) {
638 638
 	doneCh := make(chan resultTuple, parallelWriters)
639 639
 	defer close(doneCh)
640 640
 	ctx, cancel := context.WithTimeout(context.Background(), time.Duration(writeTimeSec)*time.Second)
641
-	for i := 0; i < parallelWriters; i++ {
641
+	for i := range parallelWriters {
642 642
 		key := "key-" + strconv.Itoa(i) + "-"
643 643
 		log.G(ctx).Infof("Spawn worker: %d on IP:%s", i, ips[i])
644 644
 		go writeDeleteUniqueKeys(ctx, ips[i], servicePort, networkName, tableName, key, doneCh)
... ...
@@ -650,7 +650,7 @@ func doWriteDeleteWaitLeaveJoin(ips []string, args []string) {
650 650
 	log.G(ctx).Infof("Written a total of %d keys on the cluster", keyMap[totalWrittenKeys])
651 651
 
652 652
 	// The writers will leave the network
653
-	for i := 0; i < parallelWriters; i++ {
653
+	for i := range parallelWriters {
654 654
 		log.G(ctx).Infof("worker leaveNetwork: %d on IP:%s", i, ips[i])
655 655
 		go leaveNetwork(ips[i], servicePort, networkName, doneCh)
656 656
 	}
... ...
@@ -660,7 +660,7 @@ func doWriteDeleteWaitLeaveJoin(ips []string, args []string) {
660 660
 	time.Sleep(100 * time.Millisecond)
661 661
 
662 662
 	// The writers will join the network
663
-	for i := 0; i < parallelWriters; i++ {
663
+	for i := range parallelWriters {
664 664
 		log.G(ctx).Infof("worker joinNetwork: %d on IP:%s", i, ips[i])
665 665
 		go joinNetwork(ips[i], servicePort, networkName, doneCh)
666 666
 	}
... ...
@@ -684,7 +684,7 @@ func doWriteWaitLeave(ips []string, args []string) {
684 684
 	doneCh := make(chan resultTuple, parallelWriters)
685 685
 	defer close(doneCh)
686 686
 	ctx, cancel := context.WithTimeout(context.Background(), time.Duration(writeTimeSec)*time.Second)
687
-	for i := 0; i < parallelWriters; i++ {
687
+	for i := range parallelWriters {
688 688
 		key := "key-" + strconv.Itoa(i) + "-"
689 689
 		log.G(ctx).Infof("Spawn worker: %d on IP:%s", i, ips[i])
690 690
 		go writeUniqueKeys(ctx, ips[i], servicePort, networkName, tableName, key, doneCh)
... ...
@@ -696,7 +696,7 @@ func doWriteWaitLeave(ips []string, args []string) {
696 696
 	log.G(ctx).Infof("Written a total of %d keys on the cluster", keyMap[totalWrittenKeys])
697 697
 
698 698
 	// The writers will leave the network
699
-	for i := 0; i < parallelWriters; i++ {
699
+	for i := range parallelWriters {
700 700
 		log.G(ctx).Infof("worker leaveNetwork: %d on IP:%s", i, ips[i])
701 701
 		go leaveNetwork(ips[i], servicePort, networkName, doneCh)
702 702
 	}
... ...
@@ -721,7 +721,7 @@ func doWriteWaitLeaveJoin(ips []string, args []string) {
721 721
 	doneCh := make(chan resultTuple, parallelWriters)
722 722
 	defer close(doneCh)
723 723
 	ctx, cancel := context.WithTimeout(context.Background(), time.Duration(writeTimeSec)*time.Second)
724
-	for i := 0; i < parallelWriters; i++ {
724
+	for i := range parallelWriters {
725 725
 		key := "key-" + strconv.Itoa(i) + "-"
726 726
 		log.G(ctx).Infof("Spawn worker: %d on IP:%s", i, ips[i])
727 727
 		go writeUniqueKeys(ctx, ips[i], servicePort, networkName, tableName, key, doneCh)
... ...
@@ -734,7 +734,7 @@ func doWriteWaitLeaveJoin(ips []string, args []string) {
734 734
 
735 735
 	keysExpected := keyMap[totalWrittenKeys]
736 736
 	// The Leavers will leave the network
737
-	for i := 0; i < parallelLeaver; i++ {
737
+	for i := range parallelLeaver {
738 738
 		log.G(ctx).Infof("worker leaveNetwork: %d on IP:%s", i, ips[i])
739 739
 		go leaveNetwork(ips[i], servicePort, networkName, doneCh)
740 740
 		// Once a node leave all the keys written previously will be deleted, so the expected keys will consider that as removed
... ...
@@ -746,7 +746,7 @@ func doWriteWaitLeaveJoin(ips []string, args []string) {
746 746
 	time.Sleep(100 * time.Millisecond)
747 747
 
748 748
 	// The writers will join the network
749
-	for i := 0; i < parallelLeaver; i++ {
749
+	for i := range parallelLeaver {
750 750
 		log.G(ctx).Infof("worker joinNetwork: %d on IP:%s", i, ips[i])
751 751
 		go joinNetwork(ips[i], servicePort, networkName, doneCh)
752 752
 	}
... ...
@@ -211,7 +211,7 @@ func compareBindings(a, b []portmapperapi.PortBinding) bool {
211 211
 	if len(a) != len(b) {
212 212
 		return false
213 213
 	}
214
-	for i := 0; i < len(a); i++ {
214
+	for i := range a {
215 215
 		if !comparePortBinding(&a[i].PortBinding, &b[i].PortBinding) {
216 216
 			return false
217 217
 		}
... ...
@@ -1250,7 +1250,7 @@ func TestCreateParallel(t *testing.T) {
1250 1250
 	ipV4Data := getIPv4Data(t)
1251 1251
 
1252 1252
 	ch := make(chan error, 100)
1253
-	for i := 0; i < 100; i++ {
1253
+	for i := range 100 {
1254 1254
 		name := "net" + strconv.Itoa(i)
1255 1255
 		c.Go(t, func() {
1256 1256
 			config := &networkConfiguration{BridgeName: name, EnableIPv4: true}
... ...
@@ -1269,7 +1269,7 @@ func TestCreateParallel(t *testing.T) {
1269 1269
 	}
1270 1270
 	// wait for the go routines
1271 1271
 	var success int
1272
-	for i := 0; i < 100; i++ {
1272
+	for range 100 {
1273 1273
 		val := <-ch
1274 1274
 		if val == nil {
1275 1275
 			success++
... ...
@@ -371,7 +371,7 @@ func TestConcurrentWrites(t *testing.T) {
371 371
 	}
372 372
 
373 373
 	group := new(errgroup.Group)
374
-	for i := byte(0); i < 10; i++ {
374
+	for i := range byte(10) {
375 375
 		group.Go(func() error {
376 376
 			addr, ok := netip.AddrFromSlice([]byte{i, i, i, i})
377 377
 			assert.Assert(t, ok)
... ...
@@ -382,7 +382,7 @@ func TestConcurrentWrites(t *testing.T) {
382 382
 				},
383 383
 			}
384 384
 
385
-			for j := 0; j < 25; j++ {
385
+			for range 25 {
386 386
 				if err := Add(file.Name(), rec); err != nil {
387 387
 					return err
388 388
 				}
... ...
@@ -429,7 +429,7 @@ func benchDelete(b *testing.B) {
429 429
 
430 430
 	var records []Record
431 431
 	var toDelete []Record
432
-	for i := byte(0); i < 255; i++ {
432
+	for i := range byte(255) {
433 433
 		addr, ok := netip.AddrFromSlice([]byte{i, i, i, i})
434 434
 		assert.Assert(b, ok)
435 435
 		record := Record{
... ...
@@ -1099,7 +1099,7 @@ func testAllocateRandomDeallocate(t *testing.T, pool, subPool string, num int, s
1099 1099
 	// Allocate num ip addresses
1100 1100
 	indices := make(map[int]*net.IPNet, num)
1101 1101
 	allocated := make(map[string]bool, num)
1102
-	for i := 0; i < num; i++ {
1102
+	for i := range num {
1103 1103
 		ip, _, err := a.RequestAddress(alloc.PoolID, nil, nil)
1104 1104
 		if err != nil {
1105 1105
 			t.Fatal(err)
... ...
@@ -1202,7 +1202,7 @@ func runParallelTests(t *testing.T, instance int) {
1202 1202
 	if instance == first {
1203 1203
 		done.Wait()
1204 1204
 		// Now check each instance got a different pool
1205
-		for i := 0; i < numInstances; i++ {
1205
+		for i := range numInstances {
1206 1206
 			for j := i + 1; j < numInstances; j++ {
1207 1207
 				if types.CompareIPNet(pools[i], pools[j]) {
1208 1208
 					t.Errorf("Instance %d and %d were given the same predefined pool: %v", i, j, pools)
... ...
@@ -1240,7 +1240,7 @@ func TestRequestReleaseAddressDuplicate(t *testing.T) {
1240 1240
 
1241 1241
 	group, ctx := errgroup.WithContext(context.Background())
1242 1242
 outer:
1243
-	for n := 0; n < 10000; n++ {
1243
+	for range 10000 {
1244 1244
 		var c *net.IPNet
1245 1245
 		for {
1246 1246
 			select {
... ...
@@ -75,7 +75,7 @@ func TestRequestPoolParallel(t *testing.T) {
75 75
 	imax := 1 << (a.local4.predefined[0].Size - a.local4.predefined[0].Base.Bits())
76 76
 	allocCh := make(chan string, imax)
77 77
 
78
-	for i := 0; i < imax; i++ {
78
+	for i := range imax {
79 79
 		expected = append(expected, fmt.Sprintf("10.%d.%d.0/24", uint(i/256), i%256))
80 80
 
81 81
 		eg.Go(func() error {
... ...
@@ -177,7 +177,7 @@ func allocate(t *testing.T, tctx *testContext, parallel int64) {
177 177
 	wg.Wait()
178 178
 
179 179
 	// process results
180
-	for i := 0; i < routineNum; i++ {
180
+	for range routineNum {
181 181
 		ip := <-ch
182 182
 		if ip == nil {
183 183
 			continue
... ...
@@ -137,7 +137,7 @@ func TestConcurrencyWithWait(t *testing.T) {
137 137
 	proto := "tcp"
138 138
 
139 139
 	group := new(errgroup.Group)
140
-	for i := 0; i < 10; i++ {
140
+	for range 10 {
141 141
 		group.Go(func() error {
142 142
 			return addSomeRules(natChain, ip, port, proto, dstAddr, dstPort)
143 143
 		})
... ...
@@ -249,7 +249,7 @@ func compareIpamConfList(listA, listB []*IpamConf) bool {
249 249
 	if len(listA) != len(listB) {
250 250
 		return false
251 251
 	}
252
-	for i := 0; i < len(listA); i++ {
252
+	for i := range listA {
253 253
 		a = listA[i]
254 254
 		b = listB[i]
255 255
 		if a.PreferredPool != b.PreferredPool ||
... ...
@@ -266,7 +266,7 @@ func compareIpamInfoList(listA, listB []*IpamInfo) bool {
266 266
 	if len(listA) != len(listB) {
267 267
 		return false
268 268
 	}
269
-	for i := 0; i < len(listA); i++ {
269
+	for i := range listA {
270 270
 		a = listA[i]
271 271
 		b = listB[i]
272 272
 		if a.PoolID != b.PoolID || !compareStringMaps(a.Meta, b.Meta) ||
... ...
@@ -117,7 +117,7 @@ func queryOnLinkRoutes() []netip.Prefix {
117 117
 // prefix and the length of random bytes. The api ensures that the
118 118
 // there is no interface which exists with that name.
119 119
 func GenerateIfaceName(nlh nlwrap.Handle, prefix string, length int) (string, error) {
120
-	for i := 0; i < 3; i++ {
120
+	for range 3 {
121 121
 		name, err := GenerateRandomName(prefix, length)
122 122
 		if err != nil {
123 123
 			return "", err
... ...
@@ -51,7 +51,7 @@ func launchNode(t TestingT, conf Config) *NetworkDB {
51 51
 func createNetworkDBInstances(t TestingT, num int, namePrefix string, conf *Config) []*NetworkDB {
52 52
 	t.Helper()
53 53
 	var dbs []*NetworkDB
54
-	for i := 0; i < num; i++ {
54
+	for i := range num {
55 55
 		localConfig := *conf
56 56
 		localConfig.Hostname = fmt.Sprintf("%s%d", namePrefix, i+1)
57 57
 		localConfig.NodeID = stringid.TruncateID(stringid.GenerateRandomID())
... ...
@@ -69,7 +69,7 @@ func createNetworkDBInstances(t TestingT, num int, namePrefix string, conf *Conf
69 69
 	// Wait till the cluster creation is successful
70 70
 	check := func(t poll.LogT) poll.Result {
71 71
 		// Check that the cluster is properly created
72
-		for i := 0; i < num; i++ {
72
+		for i := range num {
73 73
 			if num != len(dbs[i].ClusterPeers()) {
74 74
 				return poll.Continue("%s:Waiting for cluster peers to be established", dbs[i].config.Hostname)
75 75
 			}
... ...
@@ -91,7 +91,7 @@ func closeNetworkDBInstances(t TestingT, dbs []*NetworkDB) {
91 91
 
92 92
 func (nDB *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool) {
93 93
 	t.Helper()
94
-	for i := 0; i < 80; i++ {
94
+	for range 80 {
95 95
 		nDB.RLock()
96 96
 		_, ok := nDB.nodes[node]
97 97
 		nDB.RUnlock()
... ...
@@ -154,7 +154,7 @@ func (nDB *NetworkDB) verifyEntryExistence(t *testing.T, tname, nid, key, value
154 154
 	t.Helper()
155 155
 	n := 80
156 156
 	var v []byte
157
-	for i := 0; i < n; i++ {
157
+	for range n {
158 158
 		var err error
159 159
 		v, err = nDB.GetEntry(tname, nid, key)
160 160
 		if present && err == nil && string(v) == value {
... ...
@@ -485,8 +485,8 @@ func TestNetworkDBCRUDMediumCluster(t *testing.T) {
485 485
 		}(db)
486 486
 	}
487 487
 
488
-	for i := 0; i < n; i++ {
489
-		for j := 0; j < n; j++ {
488
+	for i := range n {
489
+		for j := range n {
490 490
 			if i == j {
491 491
 				continue
492 492
 			}
... ...
@@ -495,13 +495,13 @@ func TestNetworkDBCRUDMediumCluster(t *testing.T) {
495 495
 		}
496 496
 	}
497 497
 
498
-	for i := 0; i < n; i++ {
498
+	for i := range n {
499 499
 		err := dbs[i].JoinNetwork("network1")
500 500
 		assert.NilError(t, err)
501 501
 	}
502 502
 
503
-	for i := 0; i < n; i++ {
504
-		for j := 0; j < n; j++ {
503
+	for i := range n {
504
+		for j := range n {
505 505
 			dbs[i].verifyNetworkExistence(t, dbs[j].config.NodeID, "network1", true)
506 506
 		}
507 507
 	}
... ...
@@ -627,16 +627,16 @@ func TestNetworkDBGarbageCollection(t *testing.T) {
627 627
 	err = dbs[1].JoinNetwork("network1")
628 628
 	assert.NilError(t, err)
629 629
 
630
-	for i := 0; i < keysWriteDelete; i++ {
630
+	for i := range keysWriteDelete {
631 631
 		err = dbs[i%2].CreateEntry("testTable", "network1", "key-"+strconv.Itoa(i), []byte("value"))
632 632
 		assert.NilError(t, err)
633 633
 	}
634 634
 	time.Sleep(time.Second)
635
-	for i := 0; i < keysWriteDelete; i++ {
635
+	for i := range keysWriteDelete {
636 636
 		err = dbs[i%2].DeleteEntry("testTable", "network1", "key-"+strconv.Itoa(i))
637 637
 		assert.NilError(t, err)
638 638
 	}
639
-	for i := 0; i < 2; i++ {
639
+	for i := range 2 {
640 640
 		dbs[i].Lock()
641 641
 		assert.Check(t, is.Equal(int64(keysWriteDelete), dbs[i].thisNodeNetworks["network1"].entriesNumber.Load()), "entries number should match")
642 642
 		dbs[i].Unlock()
... ...
@@ -647,14 +647,14 @@ func TestNetworkDBGarbageCollection(t *testing.T) {
647 647
 
648 648
 	err = dbs[2].JoinNetwork("network1")
649 649
 	assert.NilError(t, err)
650
-	for i := 0; i < 3; i++ {
650
+	for i := range 3 {
651 651
 		dbs[i].Lock()
652 652
 		assert.Check(t, is.Equal(int64(keysWriteDelete), dbs[i].thisNodeNetworks["network1"].entriesNumber.Load()), "entries number should match")
653 653
 		dbs[i].Unlock()
654 654
 	}
655 655
 	// at this point the entries should had been all deleted
656 656
 	time.Sleep(30 * time.Second)
657
-	for i := 0; i < 3; i++ {
657
+	for i := range 3 {
658 658
 		dbs[i].Lock()
659 659
 		assert.Check(t, is.Equal(int64(0), dbs[i].thisNodeNetworks["network1"].entriesNumber.Load()), "entries should had been garbage collected")
660 660
 		dbs[i].Unlock()
... ...
@@ -662,7 +662,7 @@ func TestNetworkDBGarbageCollection(t *testing.T) {
662 662
 
663 663
 	// make sure that entries are not coming back
664 664
 	time.Sleep(15 * time.Second)
665
-	for i := 0; i < 3; i++ {
665
+	for i := range 3 {
666 666
 		dbs[i].Lock()
667 667
 		assert.Check(t, is.Equal(int64(0), dbs[i].thisNodeNetworks["network1"].entriesNumber.Load()), "entries should had been garbage collected")
668 668
 		dbs[i].Unlock()
... ...
@@ -832,7 +832,7 @@ func TestParallelCreate(t *testing.T) {
832 832
 	startCh := make(chan int)
833 833
 	doneCh := make(chan error)
834 834
 	var success atomic.Uint32
835
-	for i := 0; i < 20; i++ {
835
+	for range 20 {
836 836
 		go func() {
837 837
 			<-startCh
838 838
 			err := dbs[0].CreateEntry("testTable", "testNetwork", "key", []byte("value"))
... ...
@@ -845,7 +845,7 @@ func TestParallelCreate(t *testing.T) {
845 845
 
846 846
 	close(startCh)
847 847
 
848
-	for i := 0; i < 20; i++ {
848
+	for range 20 {
849 849
 		<-doneCh
850 850
 	}
851 851
 	close(doneCh)
... ...
@@ -864,7 +864,7 @@ func TestParallelDelete(t *testing.T) {
864 864
 	startCh := make(chan int)
865 865
 	doneCh := make(chan error)
866 866
 	var success atomic.Uint32
867
-	for i := 0; i < 20; i++ {
867
+	for range 20 {
868 868
 		go func() {
869 869
 			<-startCh
870 870
 			err := dbs[0].DeleteEntry("testTable", "testNetwork", "key")
... ...
@@ -877,7 +877,7 @@ func TestParallelDelete(t *testing.T) {
877 877
 
878 878
 	close(startCh)
879 879
 
880
-	for i := 0; i < 20; i++ {
880
+	for range 20 {
881 881
 		<-doneCh
882 882
 	}
883 883
 	close(doneCh)
... ...
@@ -923,7 +923,7 @@ func TestNetworkDBIslands(t *testing.T) {
923 923
 	}
924 924
 
925 925
 	// Now the 3 bootstrap nodes will cleanly leave, and will be properly removed from the other 2 nodes
926
-	for i := 0; i < 3; i++ {
926
+	for i := range 3 {
927 927
 		log.G(t.Context()).Infof("node %d leaving", i)
928 928
 		dbs[i].Close()
929 929
 	}
... ...
@@ -958,7 +958,7 @@ func TestNetworkDBIslands(t *testing.T) {
958 958
 	poll.WaitOn(t, check, poll.WithDelay(time.Second), poll.WithTimeout(pollTimeout()))
959 959
 
960 960
 	// Spawn again the first 3 nodes with different names but same IP:port
961
-	for i := 0; i < 3; i++ {
961
+	for i := range 3 {
962 962
 		log.G(t.Context()).Infof("node %d coming back", i)
963 963
 		conf := *dbs[i].config
964 964
 		conf.NodeID = stringid.TruncateID(stringid.GenerateRandomID())
... ...
@@ -968,7 +968,7 @@ func TestNetworkDBIslands(t *testing.T) {
968 968
 	// Give some time for the reconnect routine to run, it runs every 6s.
969 969
 	check = func(t poll.LogT) poll.Result {
970 970
 		// Verify that the cluster is again all connected. Note that the 3 previous node did not do any join
971
-		for i := 0; i < 5; i++ {
971
+		for i := range 5 {
972 972
 			db := dbs[i]
973 973
 			db.RLock()
974 974
 			if len(db.nodes) != 5 {
... ...
@@ -57,7 +57,7 @@ func (nlh Handle) Close() {
57 57
 }
58 58
 
59 59
 func retryOnIntr(f func() error) {
60
-	for attempt := 0; attempt < maxAttempts; attempt++ {
60
+	for range maxAttempts {
61 61
 		if err := f(); !errors.Is(err, netlink.ErrDumpInterrupted) {
62 62
 			return
63 63
 		}
... ...
@@ -37,7 +37,7 @@ func (d deviceFlags) String() string {
37 37
 		unknown uint32
38 38
 	)
39 39
 
40
-	for i := uint(0); i < 32; i++ {
40
+	for i := range uint(32) {
41 41
 		if d&(1<<i) != 0 {
42 42
 			if s, ok := deviceFlagStrings[deviceFlags(1<<i)]; ok {
43 43
 				flags = append(flags, s)
... ...
@@ -37,12 +37,12 @@ const (
37 37
 
38 38
 // Generates i multi-line events each with j lines
39 39
 func (l *logStream) logGenerator(lineCount int, multilineCount int) {
40
-	for i := 0; i < multilineCount; i++ {
40
+	for range multilineCount {
41 41
 		l.Log(&logger.Message{
42 42
 			Line:      []byte(multilineLogline),
43 43
 			Timestamp: time.Time{},
44 44
 		})
45
-		for j := 0; j < lineCount; j++ {
45
+		for range lineCount {
46 46
 			l.Log(&logger.Message{
47 47
 				Line:      []byte(logline),
48 48
 				Timestamp: time.Time{},
... ...
@@ -1288,7 +1288,7 @@ func TestCollectBatchMaxTotalBytes(t *testing.T) {
1288 1288
 	// no ticks, guarantee batch by size (and chan close)
1289 1289
 	stream.Close()
1290 1290
 
1291
-	for i := 0; i < expectedPuts; i++ {
1291
+	for range expectedPuts {
1292 1292
 		<-called
1293 1293
 	}
1294 1294
 	assert.Assert(t, len(calls) == expectedPuts)
... ...
@@ -1364,7 +1364,7 @@ func TestCollectBatchMaxTotalBytesWithBinary(t *testing.T) {
1364 1364
 	// no ticks, guarantee batch by size (and chan close)
1365 1365
 	stream.Close()
1366 1366
 
1367
-	for i := 0; i < expectedPuts; i++ {
1367
+	for range expectedPuts {
1368 1368
 		<-called
1369 1369
 	}
1370 1370
 	assert.Assert(t, len(calls) == expectedPuts)
... ...
@@ -1422,7 +1422,7 @@ func TestCollectBatchWithDuplicateTimestamps(t *testing.T) {
1422 1422
 	var expectedEvents []types.InputLogEvent
1423 1423
 	times := maximumLogEventsPerPut
1424 1424
 	timestamp := time.Now()
1425
-	for i := 0; i < times; i++ {
1425
+	for i := range times {
1426 1426
 		line := strconv.Itoa(i)
1427 1427
 		if i%2 == 0 {
1428 1428
 			timestamp = timestamp.Add(1 * time.Nanosecond)
... ...
@@ -1446,7 +1446,7 @@ func TestCollectBatchWithDuplicateTimestamps(t *testing.T) {
1446 1446
 	close(called)
1447 1447
 	assert.Assert(t, argument != nil)
1448 1448
 	assert.Assert(t, len(argument.LogEvents) == times)
1449
-	for i := 0; i < times; i++ {
1449
+	for i := range times {
1450 1450
 		if !reflect.DeepEqual(argument.LogEvents[i], expectedEvents[i]) {
1451 1451
 			t.Errorf("Expected event to be %v but was %v", expectedEvents[i], argument.LogEvents[i])
1452 1452
 		}
... ...
@@ -1659,7 +1659,7 @@ func TestCreateTagSuccess(t *testing.T) {
1659 1659
 
1660 1660
 func BenchmarkUnwrapEvents(b *testing.B) {
1661 1661
 	events := make([]wrappedEvent, maximumLogEventsPerPut)
1662
-	for i := 0; i < maximumLogEventsPerPut; i++ {
1662
+	for i := range maximumLogEventsPerPut {
1663 1663
 		mes := strings.Repeat("0", maximumBytesPerEvent)
1664 1664
 		events[i].inputLogEvent = types.InputLogEvent{
1665 1665
 			Message: &mes,
... ...
@@ -57,7 +57,7 @@ func TestCopier(t *testing.T) {
57 57
 
58 58
 	var stdout bytes.Buffer
59 59
 	var stderr bytes.Buffer
60
-	for i := 0; i < 30; i++ {
60
+	for range 30 {
61 61
 		if _, err := stdout.WriteString(stdoutLine + "\n"); err != nil {
62 62
 			t.Fatal(err)
63 63
 		}
... ...
@@ -131,7 +131,7 @@ func TestCopierLongLines(t *testing.T) {
131 131
 	var stdout bytes.Buffer
132 132
 	var stderr bytes.Buffer
133 133
 
134
-	for i := 0; i < 3; i++ {
134
+	for range 3 {
135 135
 		if _, err := stdout.WriteString(stdoutLongLine); err != nil {
136 136
 			t.Fatal(err)
137 137
 		}
... ...
@@ -196,7 +196,7 @@ func TestCopierLongLines(t *testing.T) {
196 196
 func TestCopierSlow(t *testing.T) {
197 197
 	stdoutLine := "Line that thinks that it is log line from docker stdout"
198 198
 	var stdout bytes.Buffer
199
-	for i := 0; i < 30; i++ {
199
+	for range 30 {
200 200
 		if _, err := stdout.WriteString(stdoutLine + "\n"); err != nil {
201 201
 			t.Fatal(err)
202 202
 		}
... ...
@@ -300,7 +300,7 @@ func TestCopierWithPartial(t *testing.T) {
300 300
 	var stderr bytes.Buffer
301 301
 	var normalMsg bytes.Buffer
302 302
 
303
-	for i := 0; i < 3; i++ {
303
+	for range 3 {
304 304
 		if _, err := stdout.WriteString(stdoutLongLine); err != nil {
305 305
 			t.Fatal(err)
306 306
 		}
... ...
@@ -479,7 +479,7 @@ func piped(b *testing.B, iterations int, delay time.Duration, buf []byte) io.Rea
479 479
 		return nil
480 480
 	}
481 481
 	go func() {
482
-		for i := 0; i < iterations; i++ {
482
+		for range iterations {
483 483
 			time.Sleep(delay)
484 484
 			if n, err := w.Write(buf); err != nil || n != len(buf) {
485 485
 				if err != nil {
... ...
@@ -168,7 +168,7 @@ func TestJSONFileLoggerWithOpts(t *testing.T) {
168 168
 		t.Fatal(err)
169 169
 	}
170 170
 	defer l.Close()
171
-	for i := 0; i < 36; i++ {
171
+	for i := range 36 {
172 172
 		if err := l.Log(&logger.Message{Line: []byte("line" + strconv.Itoa(i)), Source: "src1"}); err != nil {
173 173
 			t.Fatal(err)
174 174
 		}
... ...
@@ -98,7 +98,7 @@ type decoder struct {
98 98
 
99 99
 func (d *decoder) readRecord(size int) error {
100 100
 	var err error
101
-	for i := 0; i < maxDecodeRetry; i++ {
101
+	for range maxDecodeRetry {
102 102
 		var n int
103 103
 		n, err = io.ReadFull(d.rdr, d.buf[d.offset:size])
104 104
 		d.offset += n
... ...
@@ -43,7 +43,7 @@ func TestLog(t *testing.T) {
43 43
 	defer l.Close()
44 44
 
45 45
 	var messages []logger.Message
46
-	for i := 0; i < 100; i++ {
46
+	for range 100 {
47 47
 		messages = append(messages, logger.Message{
48 48
 			Timestamp: time.Now(),
49 49
 			Line:      append(bytes.Repeat([]byte("a"), 100), '\n'),
... ...
@@ -29,7 +29,7 @@ func TestSharedTempFileConverter(t *testing.T) {
29 29
 		uut := newSharedTempFileConverter(copyTransform(strings.ToUpper))
30 30
 		uut.TempDir = dir
31 31
 
32
-		for i := 0; i < 3; i++ {
32
+		for i := range 3 {
33 33
 			t.Logf("Iteration %v", i)
34 34
 
35 35
 			rdr := convertPath(t, uut, name)
... ...
@@ -113,7 +113,7 @@ func TestSharedTempFileConverter(t *testing.T) {
113 113
 		closers := make(chan io.Closer, 4)
114 114
 		var wg sync.WaitGroup
115 115
 		wg.Add(3)
116
-		for i := 0; i < 3; i++ {
116
+		for i := range 3 {
117 117
 			go func() {
118 118
 				defer wg.Done()
119 119
 				t.Logf("goroutine %v: enter", i)
... ...
@@ -174,7 +174,7 @@ func TestSharedTempFileConverter(t *testing.T) {
174 174
 
175 175
 		var done sync.WaitGroup
176 176
 		done.Add(3)
177
-		for i := 0; i < 3; i++ {
177
+		for i := range 3 {
178 178
 			go func() {
179 179
 				defer done.Done()
180 180
 				t.Logf("goroutine %v: enter", i)
... ...
@@ -51,7 +51,7 @@ func TestRingLogger(t *testing.T) {
51 51
 
52 52
 func TestRingCap(t *testing.T) {
53 53
 	r := newRing(5)
54
-	for i := 0; i < 10; i++ {
54
+	for i := range 10 {
55 55
 		// queue messages with "0" to "10"
56 56
 		// the "5" to "10" messages should be dropped since we only allow 5 bytes in the buffer
57 57
 		if err := r.Enqueue(&Message{Line: []byte(strconv.Itoa(i))}); err != nil {
... ...
@@ -60,7 +60,7 @@ func TestRingCap(t *testing.T) {
60 60
 	}
61 61
 
62 62
 	// should have messages in the queue for "0" to "4"
63
-	for i := 0; i < 5; i++ {
63
+	for i := range 5 {
64 64
 		m, err := r.Dequeue()
65 65
 		if err != nil {
66 66
 			t.Fatal(err)
... ...
@@ -119,7 +119,7 @@ func TestRingClose(t *testing.T) {
119 119
 
120 120
 func TestRingDrain(t *testing.T) {
121 121
 	r := newRing(5)
122
-	for i := 0; i < 5; i++ {
122
+	for i := range 5 {
123 123
 		if err := r.Enqueue(&Message{Line: []byte(strconv.Itoa(i))}); err != nil {
124 124
 			t.Fatal(err)
125 125
 		}
... ...
@@ -130,7 +130,7 @@ func TestRingDrain(t *testing.T) {
130 130
 		t.Fatal("got unexpected length after drain")
131 131
 	}
132 132
 
133
-	for i := 0; i < 5; i++ {
133
+	for i := range 5 {
134 134
 		if string(ls[i].Line) != strconv.Itoa(i) {
135 135
 			t.Fatalf("got unexpected message at position %d: %s", i, string(ls[i].Line))
136 136
 		}
... ...
@@ -827,7 +827,7 @@ func TestBatching(t *testing.T) {
827 827
 		t.Fatal(err)
828 828
 	}
829 829
 
830
-	for i := 0; i < defaultStreamChannelSize*4; i++ {
830
+	for i := range defaultStreamChannelSize * 4 {
831 831
 		if err := loggerDriver.Log(&logger.Message{Line: []byte(strconv.Itoa(i)), Source: "stdout", Timestamp: time.Now()}); err != nil {
832 832
 			t.Fatal(err)
833 833
 		}
... ...
@@ -887,7 +887,7 @@ func TestFrequency(t *testing.T) {
887 887
 		t.Fatal(err)
888 888
 	}
889 889
 
890
-	for i := 0; i < 10; i++ {
890
+	for i := range 10 {
891 891
 		if err := loggerDriver.Log(&logger.Message{Line: []byte(strconv.Itoa(i)), Source: "stdout", Timestamp: time.Now()}); err != nil {
892 892
 			t.Fatal(err)
893 893
 		}
... ...
@@ -958,7 +958,7 @@ func TestOneMessagePerRequest(t *testing.T) {
958 958
 		t.Fatal(err)
959 959
 	}
960 960
 
961
-	for i := 0; i < 10; i++ {
961
+	for i := range 10 {
962 962
 		if err := loggerDriver.Log(&logger.Message{Line: []byte(strconv.Itoa(i)), Source: "stdout", Timestamp: time.Now()}); err != nil {
963 963
 			t.Fatal(err)
964 964
 		}
... ...
@@ -1050,7 +1050,7 @@ func TestSkipVerify(t *testing.T) {
1050 1050
 		t.Fatal("Connection should not be verified")
1051 1051
 	}
1052 1052
 
1053
-	for i := 0; i < defaultStreamChannelSize*2; i++ {
1053
+	for i := range defaultStreamChannelSize * 2 {
1054 1054
 		if err := loggerDriver.Log(&logger.Message{Line: []byte(strconv.Itoa(i)), Source: "stdout", Timestamp: time.Now()}); err != nil {
1055 1055
 			t.Fatal(err)
1056 1056
 		}
... ...
@@ -1124,7 +1124,7 @@ func TestBufferMaximum(t *testing.T) {
1124 1124
 		t.Fatal("Connection should not be verified")
1125 1125
 	}
1126 1126
 
1127
-	for i := 0; i < 11; i++ {
1127
+	for i := range 11 {
1128 1128
 		if err := loggerDriver.Log(&logger.Message{Line: []byte(strconv.Itoa(i)), Source: "stdout", Timestamp: time.Now()}); err != nil {
1129 1129
 			t.Fatal(err)
1130 1130
 		}
... ...
@@ -1193,7 +1193,7 @@ func TestServerAlwaysDown(t *testing.T) {
1193 1193
 		t.Fatal("Connection should not be verified")
1194 1194
 	}
1195 1195
 
1196
-	for i := 0; i < 5; i++ {
1196
+	for i := range 5 {
1197 1197
 		if err := loggerDriver.Log(&logger.Message{Line: []byte(strconv.Itoa(i)), Source: "stdout", Timestamp: time.Now()}); err != nil {
1198 1198
 			t.Fatal(err)
1199 1199
 		}
... ...
@@ -87,7 +87,7 @@ func (daemon *Daemon) releaseName(name string) {
87 87
 
88 88
 func (daemon *Daemon) generateAndReserveName(id string) (string, error) {
89 89
 	var name string
90
-	for i := 0; i < 6; i++ {
90
+	for i := range 6 {
91 91
 		name = namesgenerator.GetRandomName(i)
92 92
 		if name[0] != '/' {
93 93
 			name = "/" + name
... ...
@@ -318,7 +318,7 @@ func TestDaemonReloadNetworkDiagnosticPort(t *testing.T) {
318 318
 	daemon.netController = controller
319 319
 
320 320
 	// Enable/Disable the server for some iterations
321
-	for i := 0; i < 10; i++ {
321
+	for range 10 {
322 322
 		enableConfig.CommonConfig.NetworkDiagnosticPort++
323 323
 		if err := daemon.Reload(enableConfig); err != nil {
324 324
 			t.Fatal(err)
... ...
@@ -33,7 +33,7 @@ func (s *DockerBenchmarkSuite) BenchmarkConcurrentContainerActions(c *testing.B)
33 33
 	outerGroup.Add(maxConcurrency)
34 34
 	chErr := make(chan error, numIterations*2*maxConcurrency)
35 35
 
36
-	for i := 0; i < maxConcurrency; i++ {
36
+	for range maxConcurrency {
37 37
 		go func() {
38 38
 			defer outerGroup.Done()
39 39
 			innerGroup := &sync.WaitGroup{}
... ...
@@ -41,7 +41,7 @@ func (s *DockerBenchmarkSuite) BenchmarkConcurrentContainerActions(c *testing.B)
41 41
 
42 42
 			go func() {
43 43
 				defer innerGroup.Done()
44
-				for i := 0; i < numIterations; i++ {
44
+				for range numIterations {
45 45
 					args := []string{"run", "-d", "busybox"}
46 46
 					args = append(args, sleepCommandForDaemonPlatform()...)
47 47
 					out, _, err := dockerCmdWithError(args...)
... ...
@@ -88,7 +88,7 @@ func (s *DockerBenchmarkSuite) BenchmarkConcurrentContainerActions(c *testing.B)
88 88
 
89 89
 			go func() {
90 90
 				defer innerGroup.Done()
91
-				for i := 0; i < numIterations; i++ {
91
+				for range numIterations {
92 92
 					out, _, err := dockerCmdWithError("ps")
93 93
 					if err != nil {
94 94
 						chErr <- errors.New(out)
... ...
@@ -200,7 +200,7 @@ func (d *Daemon) CmdRetryOutOfSequence(args ...string) (string, error) {
200 200
 		err    error
201 201
 	)
202 202
 
203
-	for i := 0; i < 10; i++ {
203
+	for range 10 {
204 204
 		output, err = d.Cmd(args...)
205 205
 		// error, no error, whatever. if we don't have "update out of
206 206
 		// sequence", we don't retry, we just return.
... ...
@@ -92,7 +92,7 @@ func (s *DockerAPISuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
92 92
 		ch = make(chan error, n)
93 93
 		wg sync.WaitGroup
94 94
 	)
95
-	for i := 0; i < n; i++ {
95
+	for range n {
96 96
 		wg.Add(1)
97 97
 		go func() {
98 98
 			defer wg.Done()
... ...
@@ -125,7 +125,7 @@ func (s *DockerAPISuite) TestLogsAPIUntilFutureFollow(c *testing.T) {
125 125
 	go func() {
126 126
 		bufReader := bufio.NewReader(reader)
127 127
 		defer reader.Close()
128
-		for i := 0; i < untilSecs; i++ {
128
+		for range untilSecs {
129 129
 			out, _, err := bufReader.ReadLine()
130 130
 			if err != nil {
131 131
 				if err == io.EOF {
... ...
@@ -148,7 +148,7 @@ func (s *DockerAPISuite) TestLogsAPIUntilFutureFollow(c *testing.T) {
148 148
 		}
149 149
 	}()
150 150
 
151
-	for i := 0; i < untilSecs; i++ {
151
+	for range untilSecs {
152 152
 		select {
153 153
 		case l := <-chLog:
154 154
 			assert.NilError(c, l.err)
... ...
@@ -149,7 +149,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdate(c *testing.T) {
149 149
 	ctx := testutil.GetContext(c)
150 150
 	const nodeCount = 3
151 151
 	var daemons [nodeCount]*daemon.Daemon
152
-	for i := 0; i < nodeCount; i++ {
152
+	for i := range nodeCount {
153 153
 		daemons[i] = s.AddDaemon(ctx, c, true, i == 0)
154 154
 	}
155 155
 	// wait for nodes ready
... ...
@@ -305,7 +305,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesFailedUpdate(c *testing.T) {
305 305
 	ctx := testutil.GetContext(c)
306 306
 	const nodeCount = 3
307 307
 	var daemons [nodeCount]*daemon.Daemon
308
-	for i := 0; i < nodeCount; i++ {
308
+	for i := range nodeCount {
309 309
 		daemons[i] = s.AddDaemon(ctx, c, true, i == 0)
310 310
 	}
311 311
 	// wait for nodes ready
... ...
@@ -344,7 +344,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *testing.T) {
344 344
 	ctx := testutil.GetContext(c)
345 345
 	const nodeCount = 3
346 346
 	var daemons [nodeCount]*daemon.Daemon
347
-	for i := 0; i < nodeCount; i++ {
347
+	for i := range nodeCount {
348 348
 		daemons[i] = s.AddDaemon(ctx, c, true, i == 0)
349 349
 	}
350 350
 	// wait for nodes ready
... ...
@@ -397,7 +397,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *testing.T) {
397 397
 	ctx := testutil.GetContext(c)
398 398
 	const nodeCount = 3
399 399
 	var daemons [nodeCount]*daemon.Daemon
400
-	for i := 0; i < nodeCount; i++ {
400
+	for i := range nodeCount {
401 401
 		daemons[i] = s.AddDaemon(ctx, c, true, i == 0)
402 402
 	}
403 403
 	// wait for nodes ready
... ...
@@ -494,7 +494,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicePlacementPrefs(c *testing.T) {
494 494
 
495 495
 	const nodeCount = 3
496 496
 	var daemons [nodeCount]*daemon.Daemon
497
-	for i := 0; i < nodeCount; i++ {
497
+	for i := range nodeCount {
498 498
 		daemons[i] = s.AddDaemon(ctx, c, true, i == 0)
499 499
 	}
500 500
 	// wait for nodes ready
... ...
@@ -816,7 +816,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *testing.T) {
816 816
 	mCount, wCount := 5, 1
817 817
 
818 818
 	var nodes []*daemon.Daemon
819
-	for i := 0; i < mCount; i++ {
819
+	for range mCount {
820 820
 		manager := s.AddDaemon(ctx, c, true, true)
821 821
 		info := manager.SwarmInfo(ctx, c)
822 822
 		assert.Equal(c, info.ControlAvailable, true)
... ...
@@ -824,7 +824,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *testing.T) {
824 824
 		nodes = append(nodes, manager)
825 825
 	}
826 826
 
827
-	for i := 0; i < wCount; i++ {
827
+	for range wCount {
828 828
 		worker := s.AddDaemon(ctx, c, true, false)
829 829
 		info := worker.SwarmInfo(ctx, c)
830 830
 		assert.Equal(c, info.ControlAvailable, false)
... ...
@@ -960,7 +960,7 @@ func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *testing.T) {
960 960
 	currentTrustRoot := info.Cluster.TLSInfo.TrustRoot
961 961
 
962 962
 	// rotate multiple times
963
-	for i := 0; i < 4; i++ {
963
+	for i := range 4 {
964 964
 		var err error
965 965
 		var cert, key []byte
966 966
 		if i%2 != 0 {
... ...
@@ -980,7 +980,7 @@ func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *testing.T) {
980 980
 
981 981
 		// poll to make sure update succeeds
982 982
 		var clusterTLSInfo swarm.TLSInfo
983
-		for j := 0; j < 18; j++ {
983
+		for range 18 {
984 984
 			info := m.SwarmInfo(ctx, c)
985 985
 
986 986
 			// the desired CA cert and key is always redacted
... ...
@@ -1002,7 +1002,7 @@ func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *testing.T) {
1002 1002
 		}
1003 1003
 		// could take another second or two for the nodes to trust the new roots after they've all gotten
1004 1004
 		// new TLS certificates
1005
-		for j := 0; j < 18; j++ {
1005
+		for range 18 {
1006 1006
 			mInfo := m.GetNode(ctx, c, m.NodeID()).Description.TLSInfo
1007 1007
 			wInfo := m.GetNode(ctx, c, w.NodeID()).Description.TLSInfo
1008 1008
 
... ...
@@ -54,7 +54,7 @@ func (s *DockerCLIAttachSuite) TestAttachMultipleAndRestart(c *testing.T) {
54 54
 		close(startDone)
55 55
 	}()
56 56
 
57
-	for i := 0; i < 3; i++ {
57
+	for range 3 {
58 58
 		go func() {
59 59
 			cmd := exec.Command(dockerBinary, "attach", "attacher")
60 60
 
... ...
@@ -1590,8 +1590,8 @@ func (s *DockerCLIBuildSuite) TestBuildExposeMorePorts(c *testing.T) {
1590 1590
 	portList := make([]string, 50)
1591 1591
 	line := make([]string, 100)
1592 1592
 	expectedPorts := make([]int, len(portList)*len(line))
1593
-	for i := 0; i < len(portList); i++ {
1594
-		for j := 0; j < len(line); j++ {
1593
+	for i := range portList {
1594
+		for j := range line {
1595 1595
 			p := i*len(line) + j + 1
1596 1596
 			line[j] = strconv.Itoa(p)
1597 1597
 			expectedPorts[p-1] = p
... ...
@@ -1127,7 +1127,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *testing.T)
1127 1127
 	maxChildren := 10
1128 1128
 	chErr := make(chan error, maxChildren)
1129 1129
 
1130
-	for i := 0; i < maxChildren; i++ {
1130
+	for i := range maxChildren {
1131 1131
 		wg.Add(1)
1132 1132
 		name := fmt.Sprintf("test%d", i)
1133 1133
 
... ...
@@ -283,7 +283,7 @@ func (s *DockerCLIExecSuite) TestExecCgroup(c *testing.T) {
283 283
 	var execCgroups []sort.StringSlice
284 284
 	errChan := make(chan error, 5)
285 285
 	// exec a few times concurrently to get consistent failure
286
-	for i := 0; i < 5; i++ {
286
+	for range 5 {
287 287
 		wg.Add(1)
288 288
 		go func() {
289 289
 			defer wg.Done()
... ...
@@ -337,7 +337,7 @@ func (s *DockerCLIExecSuite) TestExecInspectID(c *testing.T) {
337 337
 
338 338
 	// Give the exec 10 chances/seconds to start then give up and stop the test
339 339
 	tries := 10
340
-	for i := 0; i < tries; i++ {
340
+	for i := range tries {
341 341
 		// Since its still running we should see exec as part of the container
342 342
 		out = strings.TrimSpace(inspectField(c, id, "ExecIDs"))
343 343
 
... ...
@@ -360,7 +360,7 @@ func (s *DockerCLIExecSuite) TestExecInspectID(c *testing.T) {
360 360
 	cmd.Wait()
361 361
 
362 362
 	// Give the exec 10 chances/seconds to stop then give up and stop the test
363
-	for i := 0; i < tries; i++ {
363
+	for i := range tries {
364 364
 		// Since its still running we should see exec as part of the container
365 365
 		out = strings.TrimSpace(inspectField(c, id, "ExecIDs"))
366 366
 
... ...
@@ -547,7 +547,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *test
547 547
 	s.d.Start(c)
548 548
 	assert.Equal(c, s.ec.caps, 0)
549 549
 
550
-	for i := 0; i < 3; i++ {
550
+	for i := range 3 {
551 551
 		out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, fmt.Sprintf("test%d", i))
552 552
 		assert.NilError(c, err, out)
553 553
 		assert.Equal(c, s.ec.caps, 1)
... ...
@@ -62,7 +62,7 @@ LABEL label.Z="Z"`))
62 62
 	actualValues := strings.Split(out, "\n")[1:27]
63 63
 	expectedValues := [26]string{"Z", "Y", "X", "W", "V", "U", "T", "S", "R", "Q", "P", "O", "N", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"}
64 64
 
65
-	for i := 0; i < 26; i++ {
65
+	for i := range 26 {
66 66
 		echoValue := fmt.Sprintf("LABEL label.%s=%s", expectedValues[i], expectedValues[i])
67 67
 		actualValue := actualValues[i]
68 68
 		assert.Assert(c, is.Contains(actualValue, echoValue))
... ...
@@ -1123,7 +1123,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c
1123 1123
 	s.d.StartWithBusybox(ctx, c)
1124 1124
 
1125 1125
 	// Run a few containers on host network
1126
-	for i := 0; i < 10; i++ {
1126
+	for i := range 10 {
1127 1127
 		cName := fmt.Sprintf("hostc-%d", i)
1128 1128
 		out, err := s.d.Cmd("run", "-d", "--name", cName, "--net=host", "--restart=always", "busybox", "top")
1129 1129
 		assert.NilError(c, err, out)
... ...
@@ -1138,7 +1138,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c
1138 1138
 	s.d.Start(c)
1139 1139
 
1140 1140
 	// make sure all the containers are up and running
1141
-	for i := 0; i < 10; i++ {
1141
+	for i := range 10 {
1142 1142
 		err := s.d.WaitRun(fmt.Sprintf("hostc-%d", i))
1143 1143
 		assert.NilError(c, err)
1144 1144
 	}
... ...
@@ -104,7 +104,7 @@ func (s *DockerCLIPortSuite) TestPortList(c *testing.T) {
104 104
 	testRange := func() {
105 105
 		// host port ranges used
106 106
 		IDs := make([]string, 3)
107
-		for i := 0; i < 3; i++ {
107
+		for i := range 3 {
108 108
 			out = cli.DockerCmd(c, "run", "-d", "-p", "9090-9092:80", "busybox", "top").Stdout()
109 109
 			IDs[i] = strings.TrimSpace(out)
110 110
 
... ...
@@ -121,7 +121,7 @@ func (s *DockerCLIPortSuite) TestPortList(c *testing.T) {
121 121
 		// Exhausted port range did not return an error
122 122
 		assert.Assert(c, err != nil, "out: %s", out)
123 123
 
124
-		for i := 0; i < 3; i++ {
124
+		for i := range 3 {
125 125
 			cli.DockerCmd(c, "rm", "-f", IDs[i])
126 126
 		}
127 127
 	}
... ...
@@ -182,7 +182,7 @@ func assertPortList(t *testing.T, out string, expected []string) {
182 182
 		return old
183 183
 	}
184 184
 
185
-	for i := 0; i < len(expected); i++ {
185
+	for i := range expected {
186 186
 		if lines[i] == expected[i] {
187 187
 			continue
188 188
 		}
... ...
@@ -136,7 +136,7 @@ func assertContainerList(out string, expected []string) bool {
136 136
 	}
137 137
 
138 138
 	containerIDIndex := strings.Index(lines[0], "CONTAINER ID")
139
-	for i := 0; i < len(expected); i++ {
139
+	for i := range expected {
140 140
 		foundID := lines[i+1][containerIDIndex : containerIDIndex+12]
141 141
 		if foundID != expected[i][:12] {
142 142
 			return false
... ...
@@ -806,7 +806,7 @@ func (s *DockerCLIRunSuite) TestRunTwoConcurrentContainers(c *testing.T) {
806 806
 	group.Add(2)
807 807
 
808 808
 	errChan := make(chan error, 2)
809
-	for i := 0; i < 2; i++ {
809
+	for range 2 {
810 810
 		go func() {
811 811
 			defer group.Done()
812 812
 			_, _, err := dockerCmdWithError("run", "busybox", "sleep", sleepTime)
... ...
@@ -2857,7 +2857,7 @@ func (s *DockerCLIRunSuite) TestRunUnshareProc(c *testing.T) {
2857 2857
 	}()
2858 2858
 
2859 2859
 	var retErr error
2860
-	for i := 0; i < 3; i++ {
2860
+	for range 3 {
2861 2861
 		err := <-errChan
2862 2862
 		if retErr == nil && err != nil {
2863 2863
 			retErr = err
... ...
@@ -4111,7 +4111,7 @@ func (s *DockerCLIRunSuite) TestSlowStdinClosing(c *testing.T) {
4111 4111
 		skip.If(c, testEnv.GitHubActions())
4112 4112
 	}
4113 4113
 	const repeat = 3 // regression happened 50% of the time
4114
-	for i := 0; i < repeat; i++ {
4114
+	for i := range repeat {
4115 4115
 		c.Run(strconv.Itoa(i), func(c *testing.T) {
4116 4116
 			cmd := icmd.Cmd{
4117 4117
 				Command: []string{dockerBinary, "run", "--rm", "-i", "busybox", "cat"},
... ...
@@ -203,7 +203,7 @@ func (s *DockerSwarmSuite) TestServiceLogsFollow(c *testing.T) {
203 203
 		}
204 204
 	}()
205 205
 
206
-	for i := 0; i < 3; i++ {
206
+	for range 3 {
207 207
 		msg := <-ch
208 208
 		assert.NilError(c, msg.err)
209 209
 		assert.Assert(c, is.Contains(string(msg.data), "log test"))
... ...
@@ -1486,7 +1486,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
1486 1486
 	ctx := testutil.GetContext(c)
1487 1487
 	d := s.AddDaemon(ctx, c, true, true)
1488 1488
 
1489
-	for i := 0; i < 2; i++ {
1489
+	for range 2 {
1490 1490
 		// set to lock
1491 1491
 		outs, err := d.Cmd("swarm", "update", "--autolock")
1492 1492
 		assert.Assert(c, err == nil, "out: %v", outs)
... ...
@@ -1790,7 +1790,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinLeave(c *testing.T) {
1790 1790
 
1791 1791
 	// Verify that back to back join/leave does not cause panics
1792 1792
 	d1 := s.AddDaemon(ctx, c, false, false)
1793
-	for i := 0; i < 10; i++ {
1793
+	for range 10 {
1794 1794
 		out, err = d1.Cmd("swarm", "join", "--token", token, d.SwarmListenAddr())
1795 1795
 		assert.NilError(c, err)
1796 1796
 		assert.Assert(c, strings.TrimSpace(out) != "")
... ...
@@ -1808,7 +1808,7 @@ func waitForEvent(t *testing.T, d *daemon.Daemon, since string, filter string, e
1808 1808
 		return ""
1809 1809
 	}
1810 1810
 	var out string
1811
-	for i := 0; i < retry; i++ {
1811
+	for i := range retry {
1812 1812
 		until := daemonUnixTime(t)
1813 1813
 		var err error
1814 1814
 		if filter != "" {
... ...
@@ -1468,7 +1468,7 @@ func TestAccessPortPublishedOnLoopbackAddress(t *testing.T) {
1468 1468
 func sendPayloadFromHost(t *testing.T, host networking.Host, daddr, dport, payload string, check func() bool) bool {
1469 1469
 	var res bool
1470 1470
 	host.Do(t, func() {
1471
-		for i := 0; i < 10; i++ {
1471
+		for i := range 10 {
1472 1472
 			t.Logf("Sending probe #%d to %s:%s from host %s", i, daddr, dport, host.Name)
1473 1473
 			icmd.RunCommand("/bin/sh", "-c", fmt.Sprintf("echo '%s' | nc -w1 -u %s %s", payload, daddr, dport)).Assert(t, icmd.Success)
1474 1474
 
... ...
@@ -59,7 +59,7 @@ func TestContinueAfterPluginCrash(t *testing.T) {
59 59
 	go func() {
60 60
 		defer close(chErr)
61 61
 		rdr := bufio.NewReader(attach.Reader)
62
-		for i := 0; i < 5; i++ {
62
+		for range 5 {
63 63
 			_, _, err := rdr.ReadLine()
64 64
 			if err != nil {
65 65
 				chErr <- err
... ...
@@ -121,7 +121,7 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
121 121
 	// a few times, to give tasks time to be deallocated
122 122
 	poll.WaitOn(t, swarm.NoTasksForService(ctx, apiClient, serviceID2), swarm.ServicePoll)
123 123
 
124
-	for retry := 0; retry < 5; retry++ {
124
+	for range 5 {
125 125
 		_, err = apiClient.NetworkRemove(ctx, overlayID, client.NetworkRemoveOptions{})
126 126
 		// TODO(dperny): using strings.Contains for error checking is awful,
127 127
 		// but so is the fact that swarm functions don't return errdefs errors.
... ...
@@ -37,7 +37,7 @@ func TestServiceListWithStatuses(t *testing.T) {
37 37
 
38 38
 	serviceCount := 3
39 39
 	// create some services.
40
-	for i := 0; i < serviceCount; i++ {
40
+	for i := range serviceCount {
41 41
 		spec := fullSwarmServiceSpec(fmt.Sprintf("test-list-%d", i), uint64(i+1))
42 42
 		// for whatever reason, the args "-u root", when included, cause these
43 43
 		// tasks to fail and exit. instead, we'll just pass no args, which
... ...
@@ -59,7 +59,7 @@ type zeroReader struct{}
59 59
 
60 60
 func (zeroReader) Read(p []byte) (int, error) {
61 61
 	l := len(p)
62
-	for idx := 0; idx < l; idx++ {
62
+	for idx := range l {
63 63
 		p[idx] = 0
64 64
 	}
65 65
 	return l, nil
... ...
@@ -20,7 +20,7 @@ func RandomSinglePlatform(dir string, platform ocispec.Platform, source rand.Sou
20 20
 	layerCount := r.Intn(8)
21 21
 
22 22
 	var layers []ocispec.Descriptor
23
-	for i := 0; i < layerCount; i++ {
23
+	for i := range layerCount {
24 24
 		layerDesc, err := writeLayerWithOneFile(dir, "layer-"+strconv.Itoa(i), []byte(strconv.Itoa(i)))
25 25
 		if err != nil {
26 26
 			return nil, err
... ...
@@ -146,7 +146,7 @@ func BenchmarkTail(b *testing.B) {
146 146
 	}
147 147
 	defer f.Close()
148 148
 	defer os.RemoveAll(f.Name())
149
-	for i := 0; i < 10000; i++ {
149
+	for range 10000 {
150 150
 		if _, err := f.WriteString("tailfile pretty interesting line\n"); err != nil {
151 151
 			b.Fatal(err)
152 152
 		}
... ...
@@ -185,7 +185,7 @@ func TestNewTailReader(t *testing.T) {
185 185
 
186 186
 			s8 := `{"log":"Don't panic!\n","stream":"stdout","time":"2018-04-04T20:28:44.7207062Z"}`
187 187
 			jsonTest := make([]string, 0, 20)
188
-			for i := 0; i < 20; i++ {
188
+			for range 20 {
189 189
 				jsonTest = append(jsonTest, s8)
190 190
 			}
191 191