github-vet / github-vet/rangeloop-pointer-findings
richursa/bchain: blockchain/blockchain.go; 19 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [richursa/bchain](https://www.github.com/richursa/bchain) at [blockchain/blockchain.go](https://github.com/richursa/bchain/blob/172a82c81e70b8ad6b5bc91f88480dbc64d17ff4/blockchain/blockchain.go#L80-L98)
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 peer used in defer or goroutine at line 82
[Click here to see the code in its original context.](https://github.com/richursa/bchain/blob/172a82c81e70b8ad6b5bc91f88480dbc64d17ff4/blockchain/blockchain.go#L80-L98)
Click here to show the 19 line(s) of Go which triggered the analyzer.
```go
for _, peer := range peerlist {
go func() {
conn, err := net.Dial("tcp", peer+":8888")
if err != nil {
fmt.Println(err)
return
}
data := make([]byte, 100000)
data = []byte("requestLatestBlock" + "," + intToStr(int64(length)))
conn.Write(data)
data, err = ioutil.ReadAll(conn)
fmt.Println("received data = ", string(data))
if err != nil {
fmt.Println(err)
return
}
c <- string(data)
}()
}
```
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: 172a82c81e70b8ad6b5bc91f88480dbc64d17ff4
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.