github-vet / github-vet/rangeloop-pointer-findings
sqweek/sqribe: wave/io.go; 35 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [sqweek/sqribe](https://www.github.com/sqweek/sqribe) at [wave/io.go](https://github.com/sqweek/sqribe/blob/920a6cdadac38cbeafd130cb059a07c6308cd59c/wave/io.go#L131-L165)
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 id used in defer or goroutine at line 141
[Click here to see the code in its original context.](https://github.com/sqweek/sqribe/blob/920a6cdadac38cbeafd130cb059a07c6308cd59c/wave/io.go#L131-L165)
Click here to show the 35 line(s) of Go which triggered the analyzer.
```go
for id := range c.iochan {
if chunk, ok := c.chunks[id]; ok && chunk != failure {
/* chunk already in cache, no i/o necessary just bump the lru */
c.lru.touch(chunk)
continue
}
filename, offset := c.pos(id)
if offset == -1 {
/* block not written yet - back on the queue */
log.WAV.Printf("fetcher: requeing block %d\n", id)
go func() { time.Sleep(500 * time.Millisecond); c.iochan <- id }()
continue
}
if c.bytesWritten == -1 && id > c.lastChunkId {
/* this chunk is past EOF; cache nil */
c.add(id, nil)
continue
}
if fd == nil {
var err error
if fd, err = os.Open(filename); err != nil {
log.WAV.Printf("fetcher: %v\n", err)
continue
}
defer fd.Close()
}
chunk, err := c.readchunk(id, fd, offset)
if err != nil {
log.WAV.Printf("fetcher: chunk %d: %v\n", id, err)
c.add(id, failure)
continue
}
log.WAV.Printf("fetcher: read chunk %d: i0=%d len=%d\n", id, chunk.I0, len(chunk.Data))
c.add(id, chunk)
}
```
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: 920a6cdadac38cbeafd130cb059a07c6308cd59c
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.