github-vet / github-vet/rangeloop-pointer-findings
resourced/resourced: libdocker/libdocker.go; 35 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [resourced/resourced](https://www.github.com/resourced/resourced) at [libdocker/libdocker.go](https://github.com/resourced/resourced/blob/e24a4db9314d09f85d39f4a4c494dcbfcab3f009/libdocker/libdocker.go#L182-L216)
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 shortDescContainer used in defer or goroutine at line 193
[Click here to see the code in its original context.](https://github.com/resourced/resourced/blob/e24a4db9314d09f85d39f4a4c494dcbfcab3f009/libdocker/libdocker.go#L182-L216)
Click here to show the 35 line(s) of Go which triggered the analyzer.
```go
for _, shortDescContainer := range shortDescContainers {
container := &CompleteDockerContainer{}
container.NiceImageName = shortDescContainer.Image
container.Command = shortDescContainer.Command
container.Status = shortDescContainer.Status
wg.Add(1)
go func(container *CompleteDockerContainer) {
defer wg.Done()
fullDescContainer, err := client.InspectContainer(shortDescContainer.ID)
if err == nil && fullDescContainer != nil {
container.ID = fullDescContainer.ID
container.Created = fullDescContainer.Created
container.Path = fullDescContainer.Path
container.Args = fullDescContainer.Args
container.Config = fullDescContainer.Config
container.State = fullDescContainer.State
container.Image = fullDescContainer.Image
container.NetworkSettings = fullDescContainer.NetworkSettings
container.SysInitPath = fullDescContainer.SysInitPath
container.ResolvConfPath = fullDescContainer.ResolvConfPath
container.HostnamePath = fullDescContainer.HostnamePath
container.HostsPath = fullDescContainer.HostsPath
container.Name = fullDescContainer.Name
container.Driver = fullDescContainer.Driver
container.Volumes = fullDescContainer.Volumes
container.VolumesRW = fullDescContainer.VolumesRW
container.HostConfig = fullDescContainer.HostConfig
containersChan <- container
}
}(container)
}
```
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: e24a4db9314d09f85d39f4a4c494dcbfcab3f009
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.