github-vet / github-vet/rangeloop-pointer-findings
Azure/mirrorcat: merge_finder.go; 34 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Azure/mirrorcat](https://www.github.com/Azure/mirrorcat) at [merge_finder.go](https://github.com/Azure/mirrorcat/blob/64bf2169f17de24b2ffbee7f803b9f0d54c6a599/merge_finder.go#L12-L45)
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 finder used in defer or goroutine at line 23
[Click here to see the code in its original context.](https://github.com/Azure/mirrorcat/blob/64bf2169f17de24b2ffbee7f803b9f0d54c6a599/merge_finder.go#L12-L45)
Click here to show the 34 line(s) of Go which triggered the analyzer.
```go
for _, finder := range haystack {
// Due to the fact that all FindMirrors implementations must close the results channel to communicate
// that no more matches have been found, we must create a layer of separation between the merged results
// and the results from each child MirrorFinder.
intermediate := make(chan RemoteRef)
errs := make(chan error, 1)
// Kick-off a goroutine to fetch the child's matching mirrors.
go func() {
select {
case errs <- finder.FindMirrors(ctx, needle, intermediate):
// Intentionally Left Blank
case <-ctx.Done():
// This case prevents leaking this goroutine in the case that the underlying type
// of `finder` does not respect cancellation tokens appropriately.
errs <- ctx.Err()
}
}()
for mirror := range intermediate {
select {
case results <- mirror:
// Intentionally Left Blank
case <-ctx.Done():
return ctx.Err()
}
}
err = <-errs
if err != nil {
return
}
}
```
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: 64bf2169f17de24b2ffbee7f803b9f0d54c6a599
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.