github-vet / github-vet/rangeloop-pointer-findings
sensiblecodeio/hanoverd: main.go; 75 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [sensiblecodeio/hanoverd](https://www.github.com/sensiblecodeio/hanoverd) at [main.go](https://github.com/sensiblecodeio/hanoverd/blob/76e987d756ee80cb7f8de9b7e2db0500d83e4dd0/main.go#L338-L412)
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 event used in defer or goroutine at line 379
[Click here to see the code in its original context.](https://github.com/sensiblecodeio/hanoverd/blob/76e987d756ee80cb7f8de9b7e2db0500d83e4dd0/main.go#L338-L412)
Click here to show the 75 line(s) of Go which triggered the analyzer.
```go
for event := range events {
name := fmt.Sprint(containerName, "-", i)
i++
log.Printf("New container starting: %q", name)
if options.disableOverlap {
log.Printf("Overlap switched off, killing old")
flips <- nil
}
c := NewContainer(client, name, wg)
c.Args = options.containerArgs
c.Env = options.env
c.Volumes = options.volumes
var mountOpts opts.MountOpt
for _, mount := range options.mounts {
mountOpts.Set(mount) // note: set is really 'append'.
}
c.Mounts = mountOpts.Value()
c.StatusURI = options.statusURI
c.Obtained.Forward(&event.Obtained)
// Global exit should cause container exit
dying.Forward(&c.Closing)
// Cancel an existing startup, if there is one.
supercede()
supercede = c.Superceded.Fall
wg.Add(1)
go func(c *Container) {
defer wg.Done()
if imageSource == nil {
log.Printf("No image source specified")
c.Failed.Fall()
return
}
status, err := c.Run(imageSource, event.Payload)
if err != nil {
log.Println("Container run failed:", strings.TrimSpace(err.Error()))
return
}
log.Println("container", c.Name, "quit, exit status:", status)
}(c)
wg.Add(1)
go func(c *Container) {
defer wg.Done()
log.Printf("Awaiting container fate: %q %q", c.Name, c.StatusURI)
select {
case <-c.Failed.Barrier():
log.Println("Container failed before going live:", c.Name)
c.Closing.Fall()
return
case <-c.Superceded.Barrier():
log.Println("Container superceded before going live:", c.Name)
c.Closing.Fall()
return
case <-c.Closing.Barrier():
log.Println("Container closed before going live:", c.Name)
return
case <-c.Ready.Barrier():
}
log.Println("Container going live:", c.Name)
flips <- c
}(c)
}
```
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: 76e987d756ee80cb7f8de9b7e2db0500d83e4dd0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.