github-vet / github-vet/rangeloop-pointer-findings

infostellarinc/stellarcli: pkg/satellite/stream/stream.go; 31 LoC

Open
#7,382 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [infostellarinc/stellarcli](https://www.github.com/infostellarinc/stellarcli) at [pkg/satellite/stream/stream.go](https://github.com/infostellarinc/stellarcli/blob/8d68b6948c4cebfbe5c3a99b227f346d3a693675/pkg/satellite/stream/stream.go#L366-L396)

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 telemetry used in defer or goroutine at line 386

[Click here to see the code in its original context.](https://github.com/infostellarinc/stellarcli/blob/8d68b6948c4cebfbe5c3a99b227f346d3a693675/pkg/satellite/stream/stream.go#L366-L396)

Click here to show the 31 line(s) of Go which triggered the analyzer.

```go
for _, telemetry := range telResponse.Telemetry {
if telemetry == nil {
break
}
payload := telemetry.Data
log.Debug("received data: streamId: %v, planId: %s, framing type: %s, size: %d bytes\n", ss.streamId, planId, telemetry.Framing, len(payload))
if ss.enableAutoClose && len(payload) > 0 {
dataStarted = true
dataStopped = false
receivingBytes = true
latestByteTime, _ := ptypes.Timestamp(telemetry.TimeLastByteReceived)
ss.latestByteTime = latestByteTime
}
if ss.showStats {
metrics.collectTelemetry(telemetry)
}
if ss.correctOrder {
go func() {
ss.mu.Lock()
defer ss.mu.Unlock()
pq.Push(telemetry)
}()
} else {
ss.recvChan <- payload
if ss.telemetryFileWriter != nil {
if _, err := ss.telemetryFileWriter.Write(payload); err != nil {
panic(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: 8d68b6948c4cebfbe5c3a99b227f346d3a693675

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.