github-vet / github-vet/rangeloop-pointer-findings
xfwduke/limit-rm: lrm.go; 41 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [xfwduke/limit-rm](https://www.github.com/xfwduke/limit-rm) at [lrm.go](https:%2F%2Fgithub.com%2Fxfwduke%2Flimit-rm%2Fblob%2F535e7e07a47b3001c193273e3a5cc8e4fa8bd2bc%2Flrm.go%23L63-L103)
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 filePath used in defer or goroutine at line 87
[Click here to see the code in its original context.](https:%2F%2Fgithub.com%2Fxfwduke%2Flimit-rm%2Fblob%2F535e7e07a47b3001c193273e3a5cc8e4fa8bd2bc%2Flrm.go%23L63-L103)
Click here to show the 41 line(s) of Go which triggered the analyzer.
```go
for _, filePath := range opts.Args.FilePaths {
progress := make(chan int64/*, 100*/)
file, err := os.OpenFile(filePath, os.O_RDWR, 0777)
if err != nil {
panic(err)
}
fileStat, err := file.Stat()
if err != nil {
panic(err)
}
ctx, cancel := context.WithCancel(context.Background())
bar := pb.New64(fileStat.Size())
bar.SetRefreshRate(10 * time.Millisecond)
bar.SetMaxWidth(80)
bar.SetUnits(pb.U_BYTES)
bar.ShowSpeed = true
file.Close()
if opts.Detail {
go func(string, *pb.ProgressBar, chan int64) {
fmt.Println(filePath)
bar.Start()
defer func() {
bar.Finish()
cancel()
}()
for p := range progress {
bar.Add64(p)
}
}(filePath, bar, progress)
}
err = limitRM.RM(ctx, filePath, speed, progress)
if 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: 535e7e07a47b3001c193273e3a5cc8e4fa8bd2bc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.