github-vet / github-vet/rangeloop-pointer-findings
damdo/grontab: grontab.go; 45 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [damdo/grontab](https://www.github.com/damdo/grontab) at [grontab.go](https://github.com/damdo/grontab/blob/581e6c83d9669afd9253c15a29ce7c99d1b5e104/grontab.go#L440-L484)
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 task used in defer or goroutine at line 462
[Click here to see the code in its original context.](https://github.com/damdo/grontab/blob/581e6c83d9669afd9253c15a29ce7c99d1b5e104/grontab.go#L440-L484)
Click here to show the 45 line(s) of Go which triggered the analyzer.
```go
for jid, task := range jg {
// split the task command in args ([]string)
args := strings.Fields(task.Task)
// if the task is enabled, proceed with executing it
if task.Enabled {
log.Printf(green("EXEC JG(%s)[%s][%s]: %s"), jobGroupID, gid, jid, task.Task)
// keep count of the go routines spawned with a wait group for parallelism enabling/disabling
jobWaitGroup.Add(1)
if grontabConfiguration.DisableParallelism {
taskWaitGroup.Add(1)
}
go func() {
// execute the command
cmdOut, err := exec.Command(args[0], args[1:]...).CombinedOutput()
cleanOutput := strings.Replace(string(cmdOut), "\n", "", -1)
if err != nil {
log.Printf(red("Error executing: %s --> %s --> args: %#v\n"), task.Task, err, args)
}
log.Printf(
cyan("OUTP JG(%s)[%s][%s]: %s"),
jobGroupID,
gid,
jid,
cleanOutput,
)
// keep count of the go routines spawned with a wait group for parallelism
jobWaitGroup.Done()
if grontabConfiguration.DisableParallelism {
taskWaitGroup.Done()
}
}()
// keep count of the go routines spawned with a wait group for parallelism
if grontabConfiguration.DisableParallelism {
taskWaitGroup.Wait()
}
}
}
```
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: 581e6c83d9669afd9253c15a29ce7c99d1b5e104
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.