github-vet / github-vet/rangeloop-pointer-findings
docker/deploykit: pkg/cli/v0/event/tail.go; 43 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [docker/deploykit](https://www.github.com/docker/deploykit) at [pkg/cli/v0/event/tail.go](https://github.com/docker/deploykit/blob/41da4a601bbb18514c61ebaed12a229098ddcd3e/pkg/cli/v0/event/tail.go#L71-L113)
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 topic used in defer or goroutine at line 101
[Click here to see the code in its original context.](https://github.com/docker/deploykit/blob/41da4a601bbb18514c61ebaed12a229098ddcd3e/pkg/cli/v0/event/tail.go#L71-L113)
Click here to show the 43 line(s) of Go which triggered the analyzer.
```go
for _, topic := range topics {
target := *topic.Index(0)
eventTopic := topic
if path.Dir(name) != "." {
eventTopic = types.PathFromString(path.Base(name)).Join(topic)
}
client, is := eventPlugin.(event.Subscriber)
if !is {
return fmt.Errorf("not a subscriber: %s, %v", target, eventPlugin)
}
log.Debug("Subscribing", "topic", eventTopic)
stream, stop, err := client.SubscribeOn(eventTopic)
if err != nil {
return fmt.Errorf("cannot subscribe: %s, err=%v", topic, err)
}
defer close(stop)
go func() {
defer func() { done <- -1 }()
for {
select {
case evt, ok := <-stream:
if !ok {
log.Info("Server disconnected", "topic", topic)
return
}
// Scope the topic
evt.Topic = topic
collector <- evt
}
}
}()
running++
}
```
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: 41da4a601bbb18514c61ebaed12a229098ddcd3e
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.