github-vet / github-vet/rangeloop-pointer-findings
ae33/port-knock: knock/knock.go; 12 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [ae33/port-knock](https://www.github.com/ae33/port-knock) at [knock/knock.go](https://github.com/ae33/port-knock/blob/3e2cdeedd96f03751f6a3d6c5435ddef8f1a4afb/knock/knock.go#L44-L55)
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 p used in defer or goroutine at line 50
[Click here to see the code in its original context.](https://github.com/ae33/port-knock/blob/3e2cdeedd96f03751f6a3d6c5435ddef8f1a4afb/knock/knock.go#L44-L55)
Click here to show the 12 line(s) of Go which triggered the analyzer.
```go
for i, p := range c.Ports {
go func(k chan struct{}, port uint16, ourTurn int) {
<-knockTurns[ourTurn]
err := udpKnock(c.Host, port)
if err != nil {
log.Printf("error knocking %v at port %d: '%v'", c.Host, p, err)
}
k <- struct{}{}
}(knockSignals, p, i)
}
```
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: 3e2cdeedd96f03751f6a3d6c5435ddef8f1a4afb
Contributor guide
No contributing guide indexed for this repository
Research direction
Read knock/knock.go lines 44-55 and the analyzer message first. Check whether the goroutine’s logged port value is safely tied to the loop iteration, then classify the finding with the appropriate reaction. Done means leaving a Bug, Mitigated, or Desirable Behavior reaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100