github-vet / github-vet/rangeloop-pointer-findings
mathetake/doogle: node/node.go; 57 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [mathetake/doogle](https://www.github.com/mathetake/doogle) at [node/node.go](https://github.com/mathetake/doogle/blob/9a6c6bfeb700e62bc20472bca973c392ec748fe1/node/node.go#L464-L520)
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 nAddr used in defer or goroutine at line 469
[Click here to see the code in its original context.](https://github.com/mathetake/doogle/blob/9a6c6bfeb700e62bc20472bca973c392ec748fe1/node/node.go#L464-L520)
Click here to show the 57 line(s) of Go which triggered the analyzer.
```go
for _, nAddr := range nas {
wg.Add(1)
go func() {
defer wg.Done()
conn, err := n.getConnByNetworkAddress(nAddr)
if err != nil {
return
}
c := doogle.NewDoogleClient(conn)
res, err = c.FindIndex(context.Background(), &doogle.FindIndexRequest{
Certificate: n.certificate,
DoogleAddress: targetAddr[:],
})
if err != nil {
n.logger.Errorf("failed to call FindIndex: %v", err)
return
}
if its, ok := res.Result.(*doogle.FindIndexReply_Items); ok {
for _, it := range its.Items.Items {
mux.Lock()
if v, ok := scoreMap[it.Url]; ok {
v.num++
v.sum += it.LocalRank
} else {
scoreMap[it.Url] = &struct {
num int
sum float64
avg float64
}{num: 1, sum: it.LocalRank}
ret = append(ret, it)
}
mux.Unlock()
}
return
}
res, _ := res.Result.(*doogle.FindIndexReply_NodeInfos)
for _, ni := range res.NodeInfos.Infos {
conn, err := n.getConnByNetworkAddress(ni.NetworkAddress)
if err != nil {
return
}
c := doogle.NewDoogleClient(conn)
res, err := c.PingWithCertificate(context.Background(), n.certificate)
if err != nil {
n.logger.Errorf("failed to PingWithCertificate")
return
}
n.isValidSender(res)
}
}()
}
```
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: 9a6c6bfeb700e62bc20472bca973c392ec748fe1
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.