mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
cmd/vet: add waitgroup analyzer
+ relnote Fixes #18022 Change-Id: I92d1939e9d9f16824655c6c909a5f58ed9500014 Reviewed-on: https://go-review.googlesource.com/c/go/+/661519 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
903d7b7862
commit
dceb77a336
@ -24,3 +24,12 @@ specifying the command's current version.
|
||||
|
||||
### Cgo {#cgo}
|
||||
|
||||
### Vet {#vet}
|
||||
|
||||
<!-- go.dev/issue/18022 -->
|
||||
|
||||
The `go vet` command now includes the
|
||||
[waitgroup](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/waitgroup)
|
||||
analyzer, which reports misplaced calls to [sync.WaitGroup.Add].
|
||||
|
||||
|
||||
|
@ -77,4 +77,5 @@ var passAnalyzersToVet = map[string]bool{
|
||||
"unreachable": true,
|
||||
"unsafeptr": true,
|
||||
"unusedresult": true,
|
||||
"waitgroup": true,
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ To list the available checks, run "go tool vet help":
|
||||
unreachable check for unreachable code
|
||||
unsafeptr check for invalid conversions of uintptr to unsafe.Pointer
|
||||
unusedresult check for unused results of calls to some functions
|
||||
waitgroup check for misuses of sync.WaitGroup
|
||||
|
||||
For details and flags of a particular check, such as printf, run "go tool vet help printf".
|
||||
|
||||
|
@ -44,7 +44,7 @@ import (
|
||||
"golang.org/x/tools/go/analysis/passes/unreachable"
|
||||
"golang.org/x/tools/go/analysis/passes/unsafeptr"
|
||||
"golang.org/x/tools/go/analysis/passes/unusedresult"
|
||||
_ "golang.org/x/tools/go/analysis/passes/waitgroup" // vendoring placeholder
|
||||
"golang.org/x/tools/go/analysis/passes/waitgroup"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -86,6 +86,7 @@ func main() {
|
||||
unreachable.Analyzer,
|
||||
unsafeptr.Analyzer,
|
||||
unusedresult.Analyzer,
|
||||
waitgroup.Analyzer,
|
||||
)
|
||||
|
||||
// It's possible that unitchecker will exit early. In
|
||||
|
@ -70,8 +70,8 @@ func TestVet(t *testing.T) {
|
||||
"unmarshal",
|
||||
"unsafeptr",
|
||||
"unused",
|
||||
"waitgroup",
|
||||
} {
|
||||
pkg := pkg
|
||||
t.Run(pkg, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user