Browse code

libnetwork: remove redundant capturing of loop vars (copyloopvar)

libnetwork/endpoint_info.go:467:3: The copy of the 'for' variable "r" can be deleted (Go 1.22+) (copyloopvar)
r := r
^
libnetwork/firewall_linux_test.go:52:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
tc := tc
^
libnetwork/libnetwork_internal_test.go:403:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
tc := tc
^
libnetwork/libnetwork_linux_test.go:2045:3: The copy of the 'for' variable "i" can be deleted (Go 1.22+) (copyloopvar)
i := i
^
libnetwork/libnetwork_linux_test.go:2165:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
tc := tc
^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2024/11/12 20:52:36
Showing 4 changed files
... ...
@@ -464,7 +464,6 @@ func (epj *endpointJoinInfo) UnmarshalJSON(b []byte) error {
464 464
 	}
465 465
 	var StaticRoutes []*types.StaticRoute
466 466
 	for _, r := range tStaticRoute {
467
-		r := r
468 467
 		StaticRoutes = append(StaticRoutes, &r)
469 468
 	}
470 469
 	epj.StaticRoutes = StaticRoutes
... ...
@@ -49,7 +49,6 @@ func TestUserChain(t *testing.T) {
49 49
 	}
50 50
 
51 51
 	for _, tc := range tests {
52
-		tc := tc
53 52
 		t.Run(fmt.Sprintf("iptables=%v,insert=%v", tc.iptables, tc.insert), func(t *testing.T) {
54 53
 			defer netnsutils.SetupTestOSContext(t)()
55 54
 			defer resetIptables(t)
... ...
@@ -400,7 +400,6 @@ func TestUpdateSvcRecord(t *testing.T) {
400 400
 	}
401 401
 
402 402
 	for _, tc := range tests {
403
-		tc := tc
404 403
 		t.Run(tc.name, func(t *testing.T) {
405 404
 			defer netnsutils.SetupTestOSContext(t)()
406 405
 			ctrlr, err := New(config.OptionDataDir(t.TempDir()))
... ...
@@ -2042,7 +2042,6 @@ func TestParallel(t *testing.T) {
2042 2042
 
2043 2043
 	var eg errgroup.Group
2044 2044
 	for i := first; i <= last; i++ {
2045
-		i := i
2046 2045
 		eg.Go(func() error { return pt.Do(t, i) })
2047 2046
 	}
2048 2047
 	if err := eg.Wait(); err != nil {
... ...
@@ -2162,7 +2161,6 @@ func TestNullIpam(t *testing.T) {
2162 2162
 	}
2163 2163
 
2164 2164
 	for _, tc := range tests {
2165
-		tc := tc
2166 2165
 		t.Run(tc.networkType, func(t *testing.T) {
2167 2166
 			_, err := controller.NewNetwork(tc.networkType, "tnet1-"+tc.networkType, "",
2168 2167
 				libnetwork.NetworkOptionEnableIPv4(true),