github-vet / github-vet/rangeloop-pointer-findings
gzgithub/pwd: pwd/session.go; 23 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [gzgithub/pwd](https://www.github.com/gzgithub/pwd) at [pwd/session.go](https://github.com/gzgithub/pwd/blob/ca99f3ce1fb9b406cdb6493019c8414c8c19ddb6/pwd/session.go#L293-L315)
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 cmd used in defer or goroutine at line 296
[Click here to see the code in its original context.](https://github.com/gzgithub/pwd/blob/ca99f3ce1fb9b406cdb6493019c8414c8c19ddb6/pwd/session.go#L293-L315)
Click here to show the 23 line(s) of Go which triggered the analyzer.
```go
for _, cmd := range conf.Run {
errch := make(chan error)
go func() {
exitCode, err := p.InstanceExec(i, cmd)
fmt.Printf("Finished execuing command [%s] on instance %s with code [%d] and err [%v]\n", cmd, i.Name, exitCode, err)
if err != nil {
errch <- err
}
if exitCode != 0 {
errch <- fmt.Errorf("Command returned %d on instance %s", exitCode, i.IP)
}
errch <- nil
}()
// ctx.Done() could be called if the errgroup is cancelled due to a previous error. In that case, return immediately
select {
case err = <-errch:
return err
case <-ctx.Done():
return ctx.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](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: ca99f3ce1fb9b406cdb6493019c8414c8c19ddb6
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.