From c2b069f4db2adcbc86cf5b912741e4eb42505b09 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 29 Oct 2019 14:08:12 +0100 Subject: [PATCH] opts: Using the variable on range scope `tc` in function literal (scopelint) ``` opts/network_test.go:74:35: Using the variable on range scope `tc` in function literal (scopelint) assert.NilError(t, network.Set(tc.value)) ^ opts/network_test.go:102:40: Using the variable on range scope `tc` in function literal (scopelint) assert.ErrorContains(t, network.Set(tc.value), tc.expectedError) ^ opts/opts_test.go:270:30: Using the variable on range scope `tc` in function literal (scopelint) val, err := ValidateLabel(tc.value) ^ opts/opts_test.go:271:7: Using the variable on range scope `tc` in function literal (scopelint) if tc.expectedErr != "" { ^ ``` Signed-off-by: Sebastiaan van Stijn --- opts/network_test.go | 2 ++ opts/opts_test.go | 1 + 2 files changed, 3 insertions(+) diff --git a/opts/network_test.go b/opts/network_test.go index 1867d8ac8b..0d38955dc5 100644 --- a/opts/network_test.go +++ b/opts/network_test.go @@ -69,6 +69,7 @@ func TestNetworkOptAdvancedSyntax(t *testing.T) { }, } for _, tc := range testCases { + tc := tc t.Run(tc.value, func(t *testing.T) { var network NetworkOpt assert.NilError(t, network.Set(tc.value)) @@ -96,6 +97,7 @@ func TestNetworkOptAdvancedSyntaxInvalid(t *testing.T) { }, } for _, tc := range testCases { + tc := tc t.Run(tc.value, func(t *testing.T) { var network NetworkOpt assert.ErrorContains(t, network.Set(tc.value), tc.expectedError) diff --git a/opts/opts_test.go b/opts/opts_test.go index 4d5ef1749e..9c9f9689ff 100644 --- a/opts/opts_test.go +++ b/opts/opts_test.go @@ -266,6 +266,7 @@ func TestValidateLabel(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.name, func(t *testing.T) { val, err := ValidateLabel(tc.value) if tc.expectedErr != "" {