github-vet / github-vet/rangeloop-pointer-findings
kanatohodets/carbonsearch: consumer/kafka/kafka.go; 28 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [kanatohodets/carbonsearch](https://www.github.com/kanatohodets/carbonsearch) at [consumer/kafka/kafka.go](https://github.com/kanatohodets/carbonsearch/blob/c92fe8f5b6d93bc44451d1b0f95af1c53e6a2cae/consumer/kafka/kafka.go#L137-L164)
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 partition used in defer or goroutine at line 149
[Click here to see the code in its original context.](https://github.com/kanatohodets/carbonsearch/blob/c92fe8f5b6d93bc44451d1b0f95af1c53e6a2cae/consumer/kafka/kafka.go#L137-L164)
Click here to show the 28 line(s) of Go which triggered the analyzer.
```go
for _, partition := range partitionList {
pc, err := k.consumer.ConsumePartition(topic, partition, k.initialOffset)
if err != nil {
close(k.shutdown)
return fmt.Errorf("kafka consumer: Failed to start consumer of topic %s for partition %d: %s", topic, partition, err)
}
go func(pc sarama.PartitionConsumer) {
<-k.shutdown
//TODO(btyler) AsyncClose and wait on pc.Messages/pc.Errors?
err := pc.Close()
if err != nil {
logger.Logf("kafka consumer: Failed to close partition %v: %v", partition, err)
}
}(pc)
k.trackPosition(topic, partition, 0, 0, pc.HighWaterMarkOffset())
switch k.topicMapping[topic] {
case "metric":
go k.readMetric(pc, db)
case "tag":
go k.readTag(pc, db)
case "custom":
go k.readCustom(pc, db)
default:
panic(fmt.Sprintf("There's no topic mapping for %s in the kafka consumer config file. Topic mappings can be 'metric', 'tag', or 'custom'", topic))
}
}
```
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: c92fe8f5b6d93bc44451d1b0f95af1c53e6a2cae
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.