github-vet / github-vet/rangeloop-pointer-findings
RevolvInc/heka-influxdb-output: influxdb_output.go; 53 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [RevolvInc/heka-influxdb-output](https://www.github.com/RevolvInc/heka-influxdb-output) at [influxdb_output.go](https://github.com/RevolvInc/heka-influxdb-output/blob/acc33eb69bcb147d0d807a57ac693ca9336b6f71/influxdb_output.go#L225-L277)
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 pts used in defer or goroutine at line 235
[Click here to see the code in its original context.](https://github.com/RevolvInc/heka-influxdb-output/blob/acc33eb69bcb147d0d807a57ac693ca9336b6f71/influxdb_output.go#L225-L277)
Click here to show the 53 line(s) of Go which triggered the analyzer.
```go
for pts := range flushChan {
r, w := io.Pipe()
go func() {
buf.Reset()
jenc := json.NewEncoder(buf)
buf.Write([]byte{'['})
var firstPoint bool
var lastSeries string
for i, pt := range pts {
if pt.series != lastSeries {
if i != 0 {
buf.Write([]byte(`]},`))
buf.WriteTo(w)
}
buf.Write([]byte(`{"name":`))
jenc.Encode(pt.series)
buf.Write([]byte(`,"columns":`))
jenc.Encode(o.columns)
buf.Write([]byte(`,"points":[`))
lastSeries = pt.series
firstPoint = true
}
if firstPoint {
firstPoint = false
} else {
buf.Write([]byte{','})
}
jenc.Encode(pt.values)
}
buf.Write([]byte(`]}]`))
buf.WriteTo(w)
err := w.Close()
if err != nil {
or.LogError(err)
}
// We're done with pts; release it back to the main loop
select {
case recycleChan <- pts:
default: // No room in the channel; let pts get GCed
}
}()
resp, err := o.httpClient.Post(o.seriesUrl, "application/json", r)
if err == nil {
resp.Body.Close()
} else {
or.LogError(err)
}
}
```
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: acc33eb69bcb147d0d807a57ac693ca9336b6f71
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.