github-vet / github-vet/rangeloop-pointer-findings
jalin107/BaiduGo: 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 [jalin107/BaiduGo](https://www.github.com/jalin107/BaiduGo) at [internal/pcscommand/util.go](https://github.com/jalin107/BaiduGo/blob/387a614cf15447cc9bd38b1a302bf91425252788/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/jalin107/BaiduGo/blob/387a614cf15447cc9bd38b1a302bf91425252788/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 := info.FilesDirectoriesList(strings.Join(names[:k], ""), false)
if err != nil {
return nil, err
}
// 多线程获取信息
wg := pcsutil.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: 387a614cf15447cc9bd38b1a302bf91425252788
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.