github-vet / github-vet/rangeloop-pointer-findings
weylau/mcenter: app/app.go; 50 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [weylau/mcenter](https://www.github.com/weylau/mcenter) at [app/app.go](https://github.com/weylau/mcenter/blob/212676e1b7b03da512f4c5b8a50b0fa4501b0279/app/app.go#L107-L156)
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 qc used in defer or goroutine at line 123
[Click here to see the code in its original context.](https://github.com/weylau/mcenter/blob/212676e1b7b03da512f4c5b8a50b0fa4501b0279/app/app.go#L107-L156)
Click here to show the 50 line(s) of Go which triggered the analyzer.
```go
for _, qc := range app.queues {
fmt.Println("QueueName:", qc.QueueName)
fmt.Println("BindingExchange:", qc.BindingExchange)
fmt.Println("RoutingKey:", qc.RoutingKey)
for i := 0; i < config.Conf.ReceiveNum; i++ {
wg.Add(1)
go func() {
defer wg.Done()
RECONNECT:
for {
_, channel, err := util.SetupChannel(config.Conf.AmqpHost)
if err != nil {
panic(errors.ErrorStack(errors.Trace(err)))
}
msgs, err := channel.Consume(
qc.QueueName,
"",
false,
false,
false,
false,
nil)
if err != nil {
panic(errors.ErrorStack(errors.Trace(err)))
}
for {
select {
case <-app.exit:
return
case msg, ok := <-msgs:
if !ok {
loger.Loger.Infof("receiver: channel is closed, maybe lost connection")
time.Sleep(5 * time.Second)
continue RECONNECT
}
uuidStr := uuid.NewV4()
msg.MessageId = fmt.Sprintf("%s", uuidStr)
newMessage := message.Message{
QueueConfig: qc,
AmqpDelivery: &msg,
}
app.receiveChan <- &newMessage
}
}
}
}()
}
}
```
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: 212676e1b7b03da512f4c5b8a50b0fa4501b0279
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.