github-vet / github-vet/rangeloop-pointer-findings
tehbilly/gmudc: telnet/telnet.go; 13 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [tehbilly/gmudc](https://www.github.com/tehbilly/gmudc) at [telnet/telnet.go](https://github.com/tehbilly/gmudc/blob/28f45833c1e1666e3009b34574c5b047b007ab85/telnet/telnet.go#L159-L171)
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 i used in defer or goroutine at line 168
[Click here to see the code in its original context.](https://github.com/tehbilly/gmudc/blob/28f45833c1e1666e3009b34574c5b047b007ab85/telnet/telnet.go#L159-L171)
Click here to show the 13 line(s) of Go which triggered the analyzer.
```go
for i, h := range p.conn.handlers {
// A new copy of the slice. Gotta be safe.
m := make([]byte, len(bs))
copy(m, bs)
err := h.send(m)
if err != nil {
go func() { // Using a mutex, so safe to launch these off
p.conn.handlerMutex.Lock()
defer p.conn.handlerMutex.Unlock()
p.conn.handlers = append(p.conn.handlers[:i], p.conn.handlers[i+1:]...)
}()
}
}
```
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: 28f45833c1e1666e3009b34574c5b047b007ab85
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.