github-vet / github-vet/rangeloop-pointer-findings
Grenfis/omxweb: omxremote.go; 27 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Grenfis/omxweb](https://www.github.com/Grenfis/omxweb) at [omxremote.go](https://github.com/Grenfis/omxweb/blob/6410a027a9d18987f878cbcd5a83e05ecc5d5138/omxremote.go#L307-L333)
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 k used in defer or goroutine at line 319
[Click here to see the code in its original context.](https://github.com/Grenfis/omxweb/blob/6410a027a9d18987f878cbcd5a83e05ecc5d5138/omxremote.go#L307-L333)
Click here to show the 27 line(s) of Go which triggered the analyzer.
```go
for k, v := range commands {
go func(key, name string) {
defer wg.Done()
args := strings.Split(name, " ")
out := bytes.NewBuffer(nil)
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout = out
cmd.Stderr = out
if err := cmd.Run(); err != nil {
log.Println("Failed to execute command", k, err)
lock.Lock()
output[key] = "N/A"
lock.Unlock()
return
}
lock.Lock()
output[key] = strings.TrimSpace(out.String())
lock.Unlock()
}(k, v)
}
```
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: 6410a027a9d18987f878cbcd5a83e05ecc5d5138
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.