github-vet / github-vet/rangeloop-pointer-findings
xuruiray/godepView: file.go; 34 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [xuruiray/godepView](https://www.github.com/xuruiray/godepView) at [file.go](https://github.com/xuruiray/godepView/blob/bbee52d5bcbca2ce98113f9d823a79fdbc6a48f3/file.go#L51-L84)
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 path used in defer or goroutine at line 59
[Click here to see the code in its original context.](https://github.com/xuruiray/godepView/blob/bbee52d5bcbca2ce98113f9d823a79fdbc6a48f3/file.go#L51-L84)
Click here to show the 34 line(s) of Go which triggered the analyzer.
```go
for _, path := range paths {
wg.Add(1)
go func() {
defer wg.Done()
// 跳过隐藏文件
// FIXME:这段代码在并发情况下会出现误判情况
nameArray := strings.Split(path, SPILT)
if strings.HasPrefix(nameArray[len(nameArray)-1], ".") {
return
}
// 跳过非文件夹类型文件
if fi, err := os.Stat(path); err != nil || !fi.IsDir() {
return
}
f, err := os.Open(path)
if err != nil {
return
}
names, err := f.Readdirnames(0)
if err != nil {
return
}
f.Close()
for _, name := range names {
childPath = append(childPath, path+SPILT+name)
}
}()
}
```
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: bbee52d5bcbca2ce98113f9d823a79fdbc6a48f3
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.