github-vet / github-vet/rangeloop-pointer-findings
gschier/will-you-please: internal/run.go; 50 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [gschier/will-you-please](https://www.github.com/gschier/will-you-please) at [internal/run.go](https://github.com/gschier/will-you-please/blob/ece63c172937445778a8b66b53fbdc0d17b4e7dc/internal/run.go#L57-L106)
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 r used in defer or goroutine at line 73
[Click here to see the code in its original context.](https://github.com/gschier/will-you-please/blob/ece63c172937445778a8b66b53fbdc0d17b4e7dc/internal/run.go#L57-L106)
Click here to show the 50 line(s) of Go which triggered the analyzer.
```go
for _, r := range rg.runs {
// Something else already starting it
if r.startLock {
continue
}
// Kill it if it's already running
if r.cmd != nil && r.cmd.ProcessState == nil {
_ = r.cmd.Process.Kill()
}
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
sig := <-sigs
fmt.Printf("[wyp] Signalling %s with %s\n", r.script.Name(), sig)
err := r.cmd.Process.Signal(sig)
if err != nil {
fmt.Println("[wyp] Failed to signal", r.script.Name(), err)
}
}()
// Make a new command
r.cmd = mkCmd(rg.ctx, r.script, r.index)
r.startLock = true
go func(r *run) {
err := r.cmd.Start()
if err != nil {
panic(err)
}
r.startLock = false
r.pid = r.cmd.Process.Pid
_ = r.cmd.Wait()
allDone := true
for _, r := range rg.runs {
if r.cmd.ProcessState == nil {
allDone = false
break
}
}
if allDone {
rg.done <- true
}
}(r)
}
```
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: ece63c172937445778a8b66b53fbdc0d17b4e7dc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.