18. Handy Commands

Quick CLI recipes for tests, profiling, modules, and GC diagnostics.

go test ./... -race -count=1
go test -run TestName -bench=. -benchmem ./pkg/...
go tool pprof -http=:0 cpu.out
go list -m -u all
go mod tidy && git diff --exit-code go.mod go.sum
GODEBUG=gctrace=1 ./app
go tool cover -func=coverage.out
# Capture CPU/heap profiles in tests
go test -cpuprofile cpu.out -memprofile mem.out ./...

# Module hygiene and graph
go mod verify && go mod graph | head -n 20

# Trace visualization from tests
go test -run=NONE -trace trace.out ./...
go tool trace trace.out