A CLI tool to discover Go modules and analyze their test coverage across directories.
test-finder recursively scans directories for Go modules (go.mod files), runs coverage analysis on each one, and reports function-level test coverage. It supports monorepos and Go workspaces out of the box.
- Recursive module discovery — finds all
go.modandgo.workfiles in a directory tree - Function-level coverage — reports per-function coverage percentages, not just package-level
- Multiple output formats — human-readable table or machine-parseable JSON
- Monorepo support — handles Go workspace files (
go.work) and nested modules - Ignored directories — skips
.git,vendor,node_modules,bin, and other common directories by default
go install github.com/padiazg/test-finder@latestDownload the latest release from the GitHub releases page and place it on your PATH.
test-finder scantest-finder scan /path/to/project┌────────────────────┬────────────────────┬──────────────────┬───────────────┬──────────┐
│ PROJECT │ PACKAGE │ FILE │ FUNCTION │ COVERAGE │
├────────────────────┼────────────────────┼──────────────────┼───────────────┼──────────┤
│ github.com/my/repo │ github.com/my/repo │ user_service.go │ CreateUser │ 100.0% │
│ │ │ │ GetUser │ 75.0% │
│ │ │ │ DeleteUser │ 50.0% │
├────────────────────┼────────────────────┼──────────────────┼───────────────┼──────────┤
│ github.com/my/repo │ github.com/my/repo │ order_handler.go │ ProcessOrder │ 80.0% │
│ │ │ │ CancelOrder │ 0.0% │
└────────────────────┴────────────────────┴──────────────────┴───────────────┴──────────┘
test-finder scan --output json[
{
"Module": "github.com/my/repo",
"Path": "/home/user/my-repo",
"Files": [
{
"Coverage": [
{"Name": "CreateUser", "Line": 12, "Coverage": 100.0},
{"Name": "GetUser", "Line": 25, "Coverage": 75.0}
],
"FileName": "user_service.go",
"Package": "github.com/my/repo",
"Path": "/home/user/my-repo/user_service.go",
"Average": 87.5
}
]
}
]test-finder/
├── cmd/ # CLI commands (Cobra)
│ ├── root.go # Root command
│ └── scan.go # Scan subcommand
├── internal/
│ ├── project/ # Domain types (Project, FileNode, FunctionCoverage)
│ └── scan/v2/ # Module discovery and scanning logic
├── pkg/helpers/ # Utility functions (mod parsing, path helpers)
├── main.go # Entry point
└── go.mod
- Walk the target directory recursively, looking for
go.modandgo.workfiles - Parse each module file to extract the module path and directory
- Run
go test -coverprofile=coverage.out ./...for each module - Parse the coverage output with
go tool cover -functo get per-function coverage - Output results in the selected format
The following directories are automatically skipped during scanning:
| Directory | Reason |
|---|---|
.git |
Version control |
vendor |
Vendored dependencies |
node_modules |
Node.js dependencies |
.cache |
Build caches |
.idea |
IDE metadata |
bin |
Compiled binaries |
dist |
Build output |
build |
Build output |
.tmp |
Temporary files |
.opencode |
AI tool metadata |
.vscode |
Editor settings |
- Go 1.26+
- A working Go toolchain (for
go testandgo tool cover)
MIT