Skip to content

Commit dceb77a

Browse files
adonovangopherbot
authored andcommitted
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Commit-Queue: Alan Donovan <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 903d7b7 commit dceb77a

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

doc/next/3-tools.md

+9
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ specifying the command's current version.
2424

2525
### Cgo {#cgo}
2626

27+
### Vet {#vet}
28+
29+
<!-- go.dev/issue/18022 -->
30+
31+
The `go vet` command now includes the
32+
[waitgroup](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/waitgroup)
33+
analyzer, which reports misplaced calls to [sync.WaitGroup.Add].
34+
35+

src/cmd/go/internal/test/flagdefs.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/vet/doc.go

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ To list the available checks, run "go tool vet help":
5959
unreachable check for unreachable code
6060
unsafeptr check for invalid conversions of uintptr to unsafe.Pointer
6161
unusedresult check for unused results of calls to some functions
62+
waitgroup check for misuses of sync.WaitGroup
6263
6364
For details and flags of a particular check, such as printf, run "go tool vet help printf".
6465

src/cmd/vet/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import (
4444
"golang.org/x/tools/go/analysis/passes/unreachable"
4545
"golang.org/x/tools/go/analysis/passes/unsafeptr"
4646
"golang.org/x/tools/go/analysis/passes/unusedresult"
47-
_ "golang.org/x/tools/go/analysis/passes/waitgroup" // vendoring placeholder
47+
"golang.org/x/tools/go/analysis/passes/waitgroup"
4848
)
4949

5050
func main() {
@@ -86,6 +86,7 @@ func main() {
8686
unreachable.Analyzer,
8787
unsafeptr.Analyzer,
8888
unusedresult.Analyzer,
89+
waitgroup.Analyzer,
8990
)
9091

9192
// It's possible that unitchecker will exit early. In

src/cmd/vet/vet_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func TestVet(t *testing.T) {
7070
"unmarshal",
7171
"unsafeptr",
7272
"unused",
73+
"waitgroup",
7374
} {
74-
pkg := pkg
7575
t.Run(pkg, func(t *testing.T) {
7676
t.Parallel()
7777

0 commit comments

Comments
 (0)