Runs the Go race detector and goroutine-leak checker end-to-end: instrument with `go test -race`, read race reports, configure GORACE options, stress with `-count`/`-cpu`, detect goroutine leaks with go.uber.org/goleak, and gate both checks in CI. Use when a Go service has shared state accessed by concurrent goroutines, when a race-related incident needs a regression harness, or when adding `-race` to a CI matrix for a Go module. Does not cover barrier-based deterministic interleaving or forced goroutine scheduling; use race-condition-test-author for that.
79
99%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Low
Low-risk findings worth noting
Filter options for goleak.VerifyNone / goleak.VerifyTestMain, per
pkg.go.dev/go.uber.org/goleak. Pass one or more as trailing arguments to
suppress goroutines that are expected rather than leaked.
Ignores any goroutine whose top-of-stack frame is the named function. Prefer this when the library goroutine is identifiable by name.
goleak.VerifyNone(t,
goleak.IgnoreTopFunction("database/sql.(*DB).connectionOpener"),
)Ignores any goroutine whose stack contains the named function at any depth, not just the top frame. Use when the identifying frame is not at the top.
goleak.VerifyNone(t,
goleak.IgnoreAnyFunction("google.golang.org/grpc.(*ccBalancerWrapper).watcher"),
)Snapshots the goroutines already running at call time and ignores exactly those at verification.
opt := goleak.IgnoreCurrent()
// ... test logic ...
goleak.VerifyNone(t, opt)Prefer IgnoreTopFunction over IgnoreCurrent when the library goroutine
is identifiable by name: IgnoreCurrent silences goroutines that were
already running at snapshot time, which can mask leaks introduced before
the snapshot.
goleak.Cleanup(func(int)) registers a function goleak calls with the exit
code after the leak check, e.g. to log instead of failing the process. Used
with VerifyTestMain when the default exit behavior needs to change.
IgnoreTopFunction,
IgnoreAnyFunction, IgnoreCurrent, Cleanup