github-vet / github-vet/rangeloop-pointer-findings
AdamJSc/delivery-slot-checker: domain/work/jobs.go; 20 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [AdamJSc/delivery-slot-checker](https://www.github.com/AdamJSc/delivery-slot-checker) at [domain/work/jobs.go](https://github.com/AdamJSc/delivery-slot-checker/blob/aabdbed40d143f457ddc053fbde04fde33acbdf3/domain/work/jobs.go#L107-L126)
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 job used in defer or goroutine at line 119
[Click here to see the code in its original context.](https://github.com/AdamJSc/delivery-slot-checker/blob/aabdbed40d143f457ddc053fbde04fde33acbdf3/domain/work/jobs.go#L107-L126)
Click here to show the 20 line(s) of Go which triggered the analyzer.
```go
for _, job := range r.Jobs {
for _, payload := range job.Payloads {
payload.Identifier = fmt.Sprintf("%s_%s", job.Identifier, payload.Identifier)
taskWriters[payload.Identifier] = WriterWithIdentifier{Identifier: payload.Identifier, Writer: r.Writer}
if payload.Interval < minInterval {
payload.Interval = minInterval
}
go func(payload TaskPayload) {
// initial randomised interval
time.Sleep(getRandomisedInterval(payload.Interval) * time.Second)
go runTask(job.Task, payload, taskWriters[payload.Identifier], ch)
for task := range ch {
go runTask(task, payload, taskWriters[payload.Identifier], ch)
}
}(payload)
}
}
```
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: aabdbed40d143f457ddc053fbde04fde33acbdf3
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with domain/work/jobs.go at lines 107-126 and inspect how the goroutines use job.Task and payload. Check the repository's existing tests or run its test suite to understand the intended task scheduling behavior. Done means the reported range-loop capture warning is addressed without changing the intended job execution behavior.
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
- 35/100