github-vet / github-vet/bots

Detecting identifiers in struct declarations and/or arguments to anonymous functions.

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
bug false-positive vet-bot
Dominant language
Go
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

The findings in [this issue](https://github.com/github-vet/rangeclosure-findings/issues/127) can be avoided by better static analysis.

Consider the below code.
```go
for _, port := range ports {
wg.Add(1)
go func(p int, wg *sync.WaitGroup) {

done := make(chan struct{})

s.jobChan <- portJob{
open: openChan,
closed: closedChan,
filtered: filteredChan,
ip: host,
port: p,
done: done,
ctx: ctx,
}

<-done
wg.Done()

}(port, wg)
}
```

The static analysis is triggering for one of two reasons:
1) either 'port' is mentioned as the label in a struct
2) or it's finding the use of `port` as an argument to the function in the goroutine ~(I think it's probably this one)~.

Both are false-positives for our purposes so it'd be preferred if the analysis ignored these sorts of examples automatically.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.