Documentation
¶
Overview ¶
Package waitgroup defines an Analyzer that detects simple misuses of sync.WaitGroup.
Analyzer waitgroup ¶
waitgroup: check for misuses of sync.WaitGroup
This analyzer detects mistaken calls to the (*sync.WaitGroup).Add method from inside a new goroutine, causing Add to race with Wait:
// WRONG var wg sync.WaitGroup go func() { wg.Add(1) // "WaitGroup.Add called from inside new goroutine" defer wg.Done() ... }() wg.Wait() // (may return prematurely before new goroutine starts)
The correct code calls Add before starting the goroutine:
// RIGHT var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() ... }() wg.Wait()
Package waitgroup defines an Analyzer that detects simple misuses of sync.WaitGroup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Analyzer = &analysis.Analyzer{ Name: "waitgroup", Doc: analysisutil.MustExtractDoc(doc, "waitgroup"), URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/waitgroup", Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: run, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.