github-vet / github-vet/rangeloop-pointer-findings
linxiaokun528/zookeeper-operator: internal/zkcluster/scaleup.go; 12 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [linxiaokun528/zookeeper-operator](https://www.github.com/linxiaokun528/zookeeper-operator) at [internal/zkcluster/scaleup.go](https://github.com/linxiaokun528/zookeeper-operator/blob/35880de8b83bf49c9ec5b4f3e6cb254323bcd327/internal/zkcluster/scaleup.go#L37-L48)
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 member used in defer or goroutine at line 44
[Click here to see the code in its original context.](https://github.com/linxiaokun528/zookeeper-operator/blob/35880de8b83bf49c9ec5b4f3e6cb254323bcd327/internal/zkcluster/scaleup.go#L37-L48)
Click here to show the 12 line(s) of Go which triggered the analyzer.
```go
for _, member := range newMembers.GetElements() {
go func(newMember *api.Member, lastCommittedMembers *api.Members) {
defer wait.Done()
err := c.addOneMember(newMember, lastCommittedMembers)
if err != nil {
errCh <- err
c.locker.Lock()
c.zkCR.Status.Members.Unready.Remove(member.ID())
c.locker.Unlock()
}
}(member, lastCommittedMembers)
}
```
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: 35880de8b83bf49c9ec5b4f3e6cb254323bcd327
Contributor guide
No contributing guide indexed for this repository
Research direction
Read internal/zkcluster/scaleup.go around lines 37-48 and inspect how the range variable member is used inside the goroutine's error path. Compare the analyzer warning with the surrounding scale-up behavior and determine whether the finding represents a bug, mitigated issue, or desirable behavior. Done means leaving the appropriate classification reaction on the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100