github-vet / github-vet/rangeloop-pointer-findings
vitalie/worker: pool.go; 32 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [vitalie/worker](https://www.github.com/vitalie/worker) at [pool.go](https://github.com/vitalie/worker/blob/07b734afff0bae4c8771cd2856c37534befdcc83/pool.go#L169-L200)
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 msg used in defer or goroutine at line 175
[Click here to see the code in its original context.](https://github.com/vitalie/worker/blob/07b734afff0bae4c8771cd2856c37534befdcc83/pool.go#L169-L200)
Click here to show the 32 line(s) of Go which triggered the analyzer.
```go
for msg := range in {
status := NewStatusWriter()
done := make(chan struct{}, 1)
// Start the job in a separate goroutine.
go func() {
p.Exec(status, msg.Type(), msg.Args())
done <- struct{}{}
}()
ctx, cancel := context.WithTimeout(ctx, p.ttr)
defer cancel()
// Wait job completion.
select {
case <-ctx.Done():
if err := p.queue.Reject(msg); err != nil {
p.logger.Println("Reject failure:", msg, err)
}
return
case <-done:
if status.OK() {
if err := p.queue.Delete(msg); err != nil {
p.logger.Println("Delete failure:", msg, err)
}
} else {
if err := p.queue.Reject(msg); err != nil {
p.logger.Println("Reject failure:", msg, err)
}
}
}
}
```
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: 07b734afff0bae4c8771cd2856c37534befdcc83
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with pool.go at lines 169-200 in commit 07b734afff0bae4c8771cd2856c37534befdcc83, then inspect the surrounding worker behavior. Assess the analyzer's range-loop capture warning and any additional issues in the snippet; done means leaving the appropriate Bug, Mitigated, or Desirable Behavior reaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100