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 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 for more information.
Found a possible issue in Grenfis/omxweb at omxremote.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.
Click here to see the code in its original context.
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 for more information.
commit ID: 6410a027a9d18987f878cbcd5a83e05ecc5d5138