github-vet / github-vet/rangeloop-pointer-findings
lastbackend/rpc: broker.go; 66 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [lastbackend/rpc](https://www.github.com/lastbackend/rpc) at [broker.go](https://github.com/lastbackend/rpc/blob/1ff2185ca3e0c7a726eda50d8b0637a6a8e45e6d/broker.go#L283-L348)
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 d used in defer or goroutine at line 298
[Click here to see the code in its original context.](https://github.com/lastbackend/rpc/blob/1ff2185ca3e0c7a726eda50d8b0637a6a8e45e6d/broker.go#L283-L348)
Click here to show the 66 line(s) of Go which triggered the analyzer.
```go
for d := range msgs {
log.Println("RPC: message from:", d.DeliveryTag, d.ConsumerTag, string(d.Body))
s, e, p, data, err := r.decode(d.Body)
if err != nil {
log.Println("RPC: message parsing failed: ", err)
d.Ack(false)
continue
}
go func() {
if p.Name == "" {
return
}
log.Println("PRC: need upstream", d.ConsumerTag)
_, ok := r.upstreams[p.Handler]
if !ok {
log.Println("RPC: upstream not found", p.Handler)
d.Ack(false)
return
}
concurrent++
err := r.upstreams[p.Handler](s, e, data)
if err != nil {
log.Println("RPC: Proxy error:", err)
}
d.Ack(false)
concurrent--
if concurrent == 0 {
last <- true
}
}()
go func() {
if p.Name != "" {
return
}
log.Println("PRC: send to handler", d.ConsumerTag)
_, ok := r.handlers[e.Handler]
if !ok {
log.Println("RPC: handler not found", e.Handler)
d.Ack(false)
return
}
concurrent++
err := r.handlers[e.Handler](s, data)
if err != nil {
log.Println("RPC: Proxy error:", err)
}
d.Ack(false)
concurrent--
if concurrent == 0 {
last <- 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: 1ff2185ca3e0c7a726eda50d8b0637a6a8e45e6d
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.