github-vet / github-vet/rangeloop-pointer-findings
febytanzil/gobroker: pubsub/worker_rabbitmq.go; 40 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [febytanzil/gobroker](https://www.github.com/febytanzil/gobroker) at [pubsub/worker_rabbitmq.go](https://github.com/febytanzil/gobroker/blob/fdac22eebce89491707348eab501f92f19e416df/pubsub/worker_rabbitmq.go#L60-L99)
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 81
[Click here to see the code in its original context.](https://github.com/febytanzil/gobroker/blob/fdac22eebce89491707348eab501f92f19e416df/pubsub/worker_rabbitmq.go#L60-L99)
Click here to show the 40 line(s) of Go which triggered the analyzer.
```go
for msg := range deliveries {
count := int32(0)
if _, ok := msg.Headers["requeueCount"]; ok {
count, _ = msg.Headers["requeueCount"].(int32)
if maxRequeue < int(count) {
log.Printf("maxRequeue limit msg [%s|%s|%s|%d]\n", msg.Exchange, queue, string(msg.Body), count)
msg.Reject(false)
continue
}
}
err = handler(&gobroker.Message{
Body: msg.Body,
Attempts: int(count),
ContentType: msg.ContentType,
})
if nil != err {
count++
go func() {
f := make(chan futurePublish)
defer close(f)
err = r.pub.publish(exchange, msg.Body, amqp.Table{
"requeueCount": count,
}, f)
if nil != err {
log.Printf("failed to requeue msg [%s|%s|%s|%s|%d] err: %s\n", exchange, queue, msg.AppId, string(msg.Body), count, err)
return
}
ftr := <-f
if nil != ftr.err {
log.Printf("failed to requeue msg [%s|%s|%s|%s|%d] err: %s\n", exchange, queue, msg.AppId, string(msg.Body), count, ftr.err)
}
}()
msg.Reject(false)
continue
}
msg.Ack(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: fdac22eebce89491707348eab501f92f19e416df
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.