github-vet / github-vet/rangeloop-pointer-findings
acoolbest/BaiduPCS-Go: internal/pcscommand/util.go; 41 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [acoolbest/BaiduPCS-Go](https://www.github.com/acoolbest/BaiduPCS-Go) at [internal/pcscommand/util.go](https://github.com/acoolbest/BaiduPCS-Go/blob/de3a91fcc151f27b5f0d59d9f4471633b9e052d1/internal/pcscommand/util.go#L87-L127)
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 k used in defer or goroutine at line 103
[Click here to see the code in its original context.](https://github.com/acoolbest/BaiduPCS-Go/blob/de3a91fcc151f27b5f0d59d9f4471633b9e052d1/internal/pcscommand/util.go#L87-L127)
Click here to show the 41 line(s) of Go which triggered the analyzer.
```go
for k := range names {
if !patternRE.MatchString(names[k]) {
continue
}
pfiles, err := GetBaiduPCS().FilesDirectoriesList(strings.Join(names[:k], ""), baidupcs.DefaultOrderOptions)
if err != nil {
return nil, err
}
// 多线程获取信息
wg := waitgroup.NewWaitGroup(10)
for k2 := range pfiles {
wg.AddDelta()
go func(k2 int) {
ok, _ := fpath.Match(pcspath.EscapeBracketOne(names[k]), "/"+pfiles[k2].Filename)
if ok {
if k >= namesLen-1 {
wg.Lock()
paths = append(paths, pfiles[k2].Path) // 插入数据
wg.Unlock()
} else if pfiles[k2].Isdir {
recPaths, goerr := recurseParsePath(pfiles[k2].Path + strings.Join(names[k+1:], ""))
if goerr != nil {
err = goerr
return
}
wg.Lock()
paths = append(paths, recPaths...) // 插入数据
wg.Unlock()
}
}
wg.Done()
}(k2)
}
wg.Wait()
break
}
```
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: de3a91fcc151f27b5f0d59d9f4471633b9e052d1
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.