github-vet / github-vet/rangeloop-pointer-findings
waterlink/tls-adapter: adapter.go; 40 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [waterlink/tls-adapter](https://www.github.com/waterlink/tls-adapter) at [adapter.go](https://github.com/waterlink/tls-adapter/blob/c8ae73476187268bdd53f6af3649ce9dba885a79/adapter.go#L102-L141)
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 105
[Click here to see the code in its original context.](https://github.com/waterlink/tls-adapter/blob/c8ae73476187268bdd53f6af3649ce9dba885a79/adapter.go#L102-L141)
Click here to show the 40 line(s) of Go which triggered the analyzer.
```go
for topicName, topic := range topics {
if topic != nil {
go func() {
messages := topic.Messages()
for {
kafkaMessage, ok := <-messages
if !ok {
break
}
log.Print(string(kafkaMessage.Value))
dataToSend := string(kafkaMessage.Value)
msg2 := &mqtt.Publish{
Header: message.Header,
TopicName: topicName,
MessageId: 10,
Payload: mqtt.BytesPayload(dataToSend),
}
if err := msg2.Encode(conn); err != nil {
log.Print(err)
break
}
}
}()
go func() {
errors := topic.Errors()
for {
error, ok := <-errors
if !ok {
break
}
log.Print(error)
}
}()
}
}
```
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: c8ae73476187268bdd53f6af3649ce9dba885a79
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.