From go
Guidance for checking test coverage in Go. Use when the user asks about test coverage, untested code, testing gaps, or which code needs tests or when test coverage is implicitly required for a task, even if coverage is not mentioned explicitly.
npx claudepluginhub haleyrc/claude-plugins --plugin goThis skill is limited to using the following tools:
Before reading files to determine testing gaps, use `go test --cover` to verify test coverage.
Verifies tests pass on completed feature branch, presents options to merge locally, create GitHub PR, keep as-is or discard; executes choice and cleans up worktree.
Guides root cause investigation for bugs, test failures, unexpected behavior, performance issues, and build failures before proposing fixes.
Writes implementation plans from specs for multi-step tasks, mapping files and breaking into TDD bite-sized steps before coding.
Share bugs, ideas, or general feedback.
Before reading files to determine testing gaps, use go test --cover to verify test coverage.
For a quick summary:
go test --cover ./... # Generate coverage for every package in the project
go test --cover ./example/lib/log # Generate coverage numbers for a specific package
go test --cover ./example/lib/... # Generate coverage numbers for a package and all its sub-packages
This generates lines indicating the test status, package name, test run time, and percentage of statements covered. For example:
ok github.com/example/lib/assert 1.146s coverage: 83.1% of statements
For detailed coverage information:
go test --coverprofile=c.out <package selector> # Generate a coverage profile
go tool cover --func=c.out # Output per-function coverage
rm c.out # Clean up once the profile is no longer required
This will produce lines indicating the path to the file, the line number of the function-under-test, the name of the function, and the coverage percentage. For example:
github.com/haleyrc/lib/assert/assert.go:20: ContentType 100.0%