github-vet / rangeloop-pointer-findings

Issue tracker collects instances of Go code on GitHub that make use of references to range loop variables.
0 stars 0 forks source link

openshift/hive: pkg/controller/clusterdeployment/clusterdeployment_controller_test.go; 11 LoC #18448

Closed githubvet closed 3 years ago

githubvet commented 3 years ago

Found a possible issue in openshift/hive at pkg/controller/clusterdeployment/clusterdeployment_controller_test.go

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

range-loop variable envVar used in defer or goroutine at line 2428

Click here to see the code in its original context.

Click here to show the 11 line(s) of Go which triggered the analyzer. ```go for _, envVar := range test.existingEnvVars { if err := os.Setenv(envVar.Name, envVar.Value); err == nil { defer func() { if err := os.Unsetenv(envVar.Name); err != nil { t.Error(err) } }() } else { t.Error(err) } } ```

Leave a reaction on this issue to contribute to the project by classifying this instance as a Bug :-1:, Mitigated :+1:, or Desirable Behavior :rocket: See the descriptions of the classifications here for more information.

commit ID: 93e5a9fee058fd4cd308594be890c05415cb41ed