github-vet / github-vet/rangeloop-pointer-findings
MolenZhang/bcm_prom: notifier/notifier.go; 26 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [MolenZhang/bcm_prom](https://www.github.com/MolenZhang/bcm_prom) at [notifier/notifier.go](https://github.com/MolenZhang/bcm_prom/blob/a9ec58ecde438e16b0ddfe44d51c24ee375b12e3/notifier/notifier.go#L366-L391)
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 ams used in defer or goroutine at line 378
[Click here to see the code in its original context.](https://github.com/MolenZhang/bcm_prom/blob/a9ec58ecde438e16b0ddfe44d51c24ee375b12e3/notifier/notifier.go#L366-L391)
Click here to show the 26 line(s) of Go which triggered the analyzer.
```go
for _, ams := range amSets {
ams.mtx.RLock()
for _, am := range ams.ams {
wg.Add(1)
ctx, cancel := context.WithTimeout(n.ctx, ams.cfg.Timeout)
defer cancel()
go func(am alertmanager) {
u := am.url().String()
if err := n.sendOne(ctx, ams.client, u, b); err != nil {
n.logger.With("alertmanager", u).With("count", len(alerts)).Errorf("Error sending alerts: %s", err)
n.metrics.errors.WithLabelValues(u).Inc()
} else {
atomic.AddUint64(&numSuccess, 1)
}
n.metrics.latency.WithLabelValues(u).Observe(time.Since(begin).Seconds())
n.metrics.sent.WithLabelValues(u).Add(float64(len(alerts)))
wg.Done()
}(am)
}
ams.mtx.RUnlock()
}
```
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: a9ec58ecde438e16b0ddfe44d51c24ee375b12e3
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.