github-vet / github-vet/rangeloop-pointer-findings
StirlingMarketingGroup/uptime: main.go; 36 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [StirlingMarketingGroup/uptime](https://www.github.com/StirlingMarketingGroup/uptime) at [main.go](https://github.com/StirlingMarketingGroup/uptime/blob/16d290b69a6102bfa4c2a7ad2624a9a0dd9671d3/main.go#L98-L133)
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 i used in defer or goroutine at line 109
[Click here to see the code in its original context.](https://github.com/StirlingMarketingGroup/uptime/blob/16d290b69a6102bfa4c2a7ad2624a9a0dd9671d3/main.go#L98-L133)
Click here to show the 36 line(s) of Go which triggered the analyzer.
```go
for _, i := range conf.Instances {
for _, s := range i.Servers {
go func(s server) {
down := false
var downTime time.Time
for {
if scanPort(s.Address, time.Second*30) == nil {
// log.Println(s.Name, s.Address, "success")
if down {
log.Println(s.Name, "is back up")
msg := fmt.Sprintf("%s just came back up! 😄🎉🎊\nIt was down for %s", s.Name, time.Since(downTime).Round(time.Second))
for _, p := range i.Sms {
sendSMS(p, msg)
}
}
down = false
} else {
// log.Println(s.Name, s.Address, "failure")
if !down {
downTime = time.Now()
msg := s.Name + " just went down! 😢"
log.Println(s.Name, "is down")
for _, p := range i.Sms {
sendSMS(p, msg)
}
} else {
log.Println(s.Name, "is still down")
}
down = true
}
time.Sleep(time.Second * 5)
}
}(s)
}
}
```
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: 16d290b69a6102bfa4c2a7ad2624a9a0dd9671d3
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.