github-vet / github-vet/rangeloop-pointer-findings
QOSGroup/qmoon: worker/cron.go; 48 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [QOSGroup/qmoon](https://www.github.com/QOSGroup/qmoon) at [worker/cron.go](https://github.com/QOSGroup/qmoon/blob/c9564dd94e195737487ac93754da3831745dc468/worker/cron.go#L59-L106)
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 n used in defer or goroutine at line 101
[Click here to see the code in its original context.](https://github.com/QOSGroup/qmoon/blob/c9564dd94e195737487ac93754da3831745dc468/worker/cron.go#L59-L106)
Click here to show the 48 line(s) of Go which triggered the analyzer.
```go
for _, n := range nodes {
if strings.Index(n.Name, "cosmos") < 0 {
url := "tcp" + n.BaseURL[4:len(n.BaseURL)]
// client := client.NewHTTP("tcp://47.103.78.91:26657", "/websocket")
client := client.NewHTTP(url, "/websocket")
// fmt.Println("[Event] Starting listening to ", url, "/websocket")
err := client.Start()
if err != nil {
fmt.Println("[Event] Can't start websocket client [%s] - '%s'", url, err)
}
//defer client.Stop()
_, events, err := n.SubscribInflation(client)
if err != nil {
// fmt.Errorf("[Event] Exiting for error:", err)
client.Stop()
return
// dos.Exit(1)
}
go func() {
for eventData := range events {
// fmt.Println("[Event] Received event from [%s] - '%s'", url, eventData)
// fmt.Println("[Event] event data: ", eventData.Data)
// fmt.Println("[Event] events: ", eventData.Events)
inf := models.Inflation{}
for key := range eventData.Events {
switch key {
case "mint.height":
for _, runeValue := range eventData.Events[key][0] {
inf.Height = int64(runeValue)
}
break
case "mint.tokens":
if n, err := strconv.ParseInt(eventData.Events[key][0], 10, 64); err == nil {
inf.Tokens = n
} else {
fmt.Println("[Event] Inflation tokens error : %s", eventData.Events[key][0])
}
break
}
}
if (inf.Height>0 && inf.Tokens>0) {
inf.InsertOrUpdate(n.ChainID)
}
}
}()
}
}
```
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: c9564dd94e195737487ac93754da3831745dc468
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.