mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +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}
|
### 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,
|
"unreachable": true,
|
||||||
"unsafeptr": true,
|
"unsafeptr": true,
|
||||||
"unusedresult": true,
|
"unusedresult": true,
|
||||||
|
"waitgroup": true,
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ To list the available checks, run "go tool vet help":
|
|||||||
unreachable check for unreachable code
|
unreachable check for unreachable code
|
||||||
unsafeptr check for invalid conversions of uintptr to unsafe.Pointer
|
unsafeptr check for invalid conversions of uintptr to unsafe.Pointer
|
||||||
unusedresult check for unused results of calls to some functions
|
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".
|
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/unreachable"
|
||||||
"golang.org/x/tools/go/analysis/passes/unsafeptr"
|
"golang.org/x/tools/go/analysis/passes/unsafeptr"
|
||||||
"golang.org/x/tools/go/analysis/passes/unusedresult"
|
"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() {
|
func main() {
|
||||||
@ -86,6 +86,7 @@ func main() {
|
|||||||
unreachable.Analyzer,
|
unreachable.Analyzer,
|
||||||
unsafeptr.Analyzer,
|
unsafeptr.Analyzer,
|
||||||
unusedresult.Analyzer,
|
unusedresult.Analyzer,
|
||||||
|
waitgroup.Analyzer,
|
||||||
)
|
)
|
||||||
|
|
||||||
// It's possible that unitchecker will exit early. In
|
// It's possible that unitchecker will exit early. In
|
||||||
|
@ -70,8 +70,8 @@ func TestVet(t *testing.T) {
|
|||||||
"unmarshal",
|
"unmarshal",
|
||||||
"unsafeptr",
|
"unsafeptr",
|
||||||
"unused",
|
"unused",
|
||||||
|
"waitgroup",
|
||||||
} {
|
} {
|
||||||
pkg := pkg
|
|
||||||
t.Run(pkg, func(t *testing.T) {
|
t.Run(pkg, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user