github-vet / github-vet/rangeloop-pointer-findings
segmentio/emissary: eds_poller.go; 24 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [segmentio/emissary](https://www.github.com/segmentio/emissary) at [eds_poller.go](https://github.com/segmentio/emissary/blob/1c39ecad4fe1409c7b763cf0e9d587880cca22f9/eds_poller.go#L91-L114)
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 service used in defer or goroutine at line 108
[Click here to see the code in its original context.](https://github.com/segmentio/emissary/blob/1c39ecad4fe1409c7b763cf0e9d587880cca22f9/eds_poller.go#L91-L114)
Click here to show the 24 line(s) of Go which triggered the analyzer.
```go
for _, service := range services {
handlers := c.get(service)
stats.Set("eds-poller.subscriptions.count", len(handlers), stats.Tag{Name: "service", Value: service})
endpoints, err := c.resolver.Lookup(ctx, service)
if err != nil {
stats.Incr("resolver.error", stats.Tag{Name: "service", Value: service})
log.Infof("error querying resolver %s", err)
}
log.Infof("resolver found %d endpoint(s)", len(endpoints))
wg := &sync.WaitGroup{}
wg.Add(len(handlers))
// send the results to each of the handlers
for _, h := range handlers {
go func(h resultHandler) {
defer wg.Done()
h.handle(EdsResult{Service: service, Endpoints: endpoints})
}(h)
}
log.Infof("waiting for consulResultHandlers on %s", service)
wg.Wait()
}
```
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: 1c39ecad4fe1409c7b763cf0e9d587880cca22f9
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.