github-vet / github-vet/rangeloop-pointer-findings
stytch16/systemMgt-go: DiskUsage/filesys/du.go; 25 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [stytch16/systemMgt-go](https://www.github.com/stytch16/systemMgt-go) at [DiskUsage/filesys/du.go](https://github.com/stytch16/systemMgt-go/blob/262434a9c650ac59baa665ee28974bcc87f678f4/DiskUsage/filesys/du.go#L34-L58)
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 i used in defer or goroutine at line 40
[Click here to see the code in its original context.](https://github.com/stytch16/systemMgt-go/blob/262434a9c650ac59baa665ee28974bcc87f678f4/DiskUsage/filesys/du.go#L34-L58)
Click here to show the 25 line(s) of Go which triggered the analyzer.
```go
for i, root := range roots {
var wg sync.WaitGroup
wg.Add(1) /* Add 1 for every goroutine that calls WalkDir */
go walkDir(root, &wg, fileSizes[i])
go func() {
wg.Wait()
close(fileSizes[i])
}()
loop:
/* Receive data from fileSizes channel. When it has been closed, break from loop and continue to next directory. */
for {
select {
case size, ok := <-fileSizes[i]:
if !ok {
break loop
}
/* record data */
nfiles[i]++
nbytes[i] += size
case <-tick:
/* print progress report */
printProgress(nfiles[i], nbytes[i], root)
}
}
}
```
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: 262434a9c650ac59baa665ee28974bcc87f678f4
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.