github-vet / github-vet/rangeloop-pointer-findings
smsali97/pocketfs: server/services/filetransferservice.go; 23 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [smsali97/pocketfs](https://www.github.com/smsali97/pocketfs) at [server/services/filetransferservice.go](https://github.com/smsali97/pocketfs/blob/9bf8cc7ce810eec7a0b2d0a99bbe78c0238a6fe5/server/services/filetransferservice.go#L38-L60)
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 server used in defer or goroutine at line 53
[Click here to see the code in its original context.](https://github.com/smsali97/pocketfs/blob/9bf8cc7ce810eec7a0b2d0a99bbe78c0238a6fe5/server/services/filetransferservice.go#L38-L60)
Click here to show the 23 line(s) of Go which triggered the analyzer.
```go
for _, server := range serverRepository {
if !server.IsAlive {
continue
}
client, err := rpc.Dial("tcp", server.IP + ":" + RPC_PORT)
if err != nil {
fmt.Println("%v Server is down",server.IP)
}
reply := &filemessage.AskFileReply{}
waitGroup.Add(1)
go func() {
defer waitGroup.Done()
err := client.Call("FileMessage.AskForFile", fileRequest, reply)
if err != nil {
fmt.Println(" error when sending message to server ",err,server.IP)
} else {
if reply.IsSuccessful {
replies = append(replies,reply)
}
}
}()
}
```
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: 9bf8cc7ce810eec7a0b2d0a99bbe78c0238a6fe5
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.