github-vet / github-vet/rangeloop-pointer-findings
phonkee/go-pubsub: reset-hub.go; 12 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [phonkee/go-pubsub](https://www.github.com/phonkee/go-pubsub) at [reset-hub.go](https://github.com/phonkee/go-pubsub/blob/5425e5981d13057cac82067b34714e46ce45fef7/reset-hub.go#L42-L53)
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 sub used in defer or goroutine at line 47
[Click here to see the code in its original context.](https://github.com/phonkee/go-pubsub/blob/5425e5981d13057cac82067b34714e46ce45fef7/reset-hub.go#L42-L53)
Click here to show the 12 line(s) of Go which triggered the analyzer.
```go
for sub, unsent := range h.registry {
if unsent {
if sub.Match(message.Topic()) {
wg.Add(1)
go func() {
count += sub.Publish(message)
wg.Done()
}()
}
h.registry[sub] = false
}
}
```
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: 5425e5981d13057cac82067b34714e46ce45fef7
Contributor guide
No contributing guide indexed for this repository
Research direction
Read reset-hub.go lines 42-53 and inspect the goroutine launched inside the range loop, including the analyzer's warning about sub. Verify the intended publish and reset behavior, then run the repository's available tests or checks to confirm the warning is addressed without changing message delivery.
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
- Clearly specified
- Newbie friendliness
- 45/100