]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: add waitgroup analyzer
authorAlan Donovan <adonovan@google.com>
Fri, 28 Mar 2025 22:04:16 +0000 (18:04 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 1 Apr 2025 22:09:39 +0000 (15:09 -0700)
+ 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>

doc/next/3-tools.md
src/cmd/go/internal/test/flagdefs.go
src/cmd/vet/doc.go
src/cmd/vet/main.go
src/cmd/vet/vet_test.go

index 977c89670c578ad5df86db845dd73103e444ccec..886852b784eacfdd6f782abdaa1911da315032e5 100644 (file)
@@ -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].
+
+
index 0292c19d821f367e1aaaaed8a2041b28a4f9fdf1..372142467b8bf3c3c8bdcef266ef15ce0c20c118 100644 (file)
@@ -77,4 +77,5 @@ var passAnalyzersToVet = map[string]bool{
        "unreachable":      true,
        "unsafeptr":        true,
        "unusedresult":     true,
+       "waitgroup":        true,
 }
index 5b2fa3d72fd1d1bf31ba06ac36d571e29e60e8be..8e72c252ed9984e58869f9637780d05837bb4ea6 100644 (file)
@@ -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".
 
index efb6916015690384aaa5951a361e15da26b41063..c9d611f927f494e744b6ca6486429db2ebdca6fb 100644 (file)
@@ -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
index 3860895a0ae96c341d811f7fde4e37b0d36a8b77..2f89784dfcc8b11ece4a96c072de25d4f4063f71 100644 (file)
@@ -70,8 +70,8 @@ func TestVet(t *testing.T) {
                "unmarshal",
                "unsafeptr",
                "unused",
+               "waitgroup",
        } {
-               pkg := pkg
                t.Run(pkg, func(t *testing.T) {
                        t.Parallel()