github-vet / github-vet/rangeloop-pointer-findings
timvaillancourt/proxysql-freno: main.go; 24 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [timvaillancourt/proxysql-freno](https://www.github.com/timvaillancourt/proxysql-freno) at [main.go](https://github.com/timvaillancourt/proxysql-freno/blob/5a3c269200417a61a735e66fe4beb912084addd4/main.go#L49-L72)
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 id used in defer or goroutine at line 57
[Click here to see the code in its original context.](https://github.com/timvaillancourt/proxysql-freno/blob/5a3c269200417a61a735e66fe4beb912084addd4/main.go#L49-L72)
Click here to show the 24 line(s) of Go which triggered the analyzer.
```go
for id := range app.select_chan {
start := time.Now()
go func() {
var done bool
for !done {
select {
default:
var row Row
err = dbRO.Get(&row, fmt.Sprintf("SELECT id, msg FROM testbed.test WHERE id=%d", id))
if err != nil {
time.Sleep(time.Millisecond)
} else {
atomic.AddUint32(&app.select_oks, 1)
//log.Printf("select: %v, duration: %v", row, time.Since(start))
done = true
}
case <-time.After(500 * time.Millisecond):
atomic.AddUint32(&app.select_errs, 1)
log.Printf("select timed out at duration: %v", time.Since(start))
done = true
}
}
}()
}
```
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: 5a3c269200417a61a735e66fe4beb912084addd4
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.