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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-10-29 14:08:12 +01:00
parent cd3dca37b8
commit c2b069f4db
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 3 additions and 0 deletions

View File

@ -69,6 +69,7 @@ func TestNetworkOptAdvancedSyntax(t *testing.T) {
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.value, func(t *testing.T) { t.Run(tc.value, func(t *testing.T) {
var network NetworkOpt var network NetworkOpt
assert.NilError(t, network.Set(tc.value)) assert.NilError(t, network.Set(tc.value))
@ -96,6 +97,7 @@ func TestNetworkOptAdvancedSyntaxInvalid(t *testing.T) {
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.value, func(t *testing.T) { t.Run(tc.value, func(t *testing.T) {
var network NetworkOpt var network NetworkOpt
assert.ErrorContains(t, network.Set(tc.value), tc.expectedError) assert.ErrorContains(t, network.Set(tc.value), tc.expectedError)

View File

@ -266,6 +266,7 @@ func TestValidateLabel(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
val, err := ValidateLabel(tc.value) val, err := ValidateLabel(tc.value)
if tc.expectedErr != "" { if tc.expectedErr != "" {