From b5b077f2ea6790a4356f9dcdf93da1b70f79f1bd Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 12 Nov 2024 13:15:09 +0100 Subject: [PATCH] api/types/network: remove redundant capturing of loop vars (copyloopvar) api/types/network/endpoint_test.go:84:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ api/types/network/endpoint_test.go:166:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ api/types/network/ipam_test.go:127:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn --- api/types/network/endpoint_test.go | 10 ++++------ api/types/network/ipam_test.go | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/api/types/network/endpoint_test.go b/api/types/network/endpoint_test.go index 878a16f2d0..814891d4e6 100644 --- a/api/types/network/endpoint_test.go +++ b/api/types/network/endpoint_test.go @@ -23,7 +23,7 @@ func (stub subnetStub) Contains(addr net.IP) bool { } func TestEndpointIPAMConfigWithOutOfRangeAddrs(t *testing.T) { - testcases := []struct { + tests := []struct { name string ipamConfig *EndpointIPAMConfig v4Subnets []NetworkSubnet @@ -80,8 +80,7 @@ func TestEndpointIPAMConfigWithOutOfRangeAddrs(t *testing.T) { }, } - for _, tc := range testcases { - tc := tc + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -105,7 +104,7 @@ func TestEndpointIPAMConfigWithOutOfRangeAddrs(t *testing.T) { } func TestEndpointIPAMConfigWithInvalidConfig(t *testing.T) { - testcases := []struct { + tests := []struct { name string ipamConfig *EndpointIPAMConfig expectedErrors []string @@ -162,8 +161,7 @@ func TestEndpointIPAMConfigWithInvalidConfig(t *testing.T) { }, } - for _, tc := range testcases { - tc := tc + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/api/types/network/ipam_test.go b/api/types/network/ipam_test.go index 446dbae8aa..8225e56bbe 100644 --- a/api/types/network/ipam_test.go +++ b/api/types/network/ipam_test.go @@ -8,7 +8,7 @@ import ( ) func TestNetworkWithInvalidIPAM(t *testing.T) { - testcases := []struct { + tests := []struct { name string ipam IPAM ipv6 bool @@ -123,8 +123,7 @@ func TestNetworkWithInvalidIPAM(t *testing.T) { }, } - for _, tc := range testcases { - tc := tc + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { t.Parallel()