Documentation
¶
Overview ¶
Package gocov collects Go coverage by running `go test -coverprofile` in each detected module and parsing the resulting cover profile directly.
No external conversion tool is required: the profile's own `mode:` header and `file:startLine.startCol,endLine.endCol numStmts count` records carry everything the normalized model needs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseProfile ¶
ParseProfile reads a Go cover profile and returns, per file path as written in the profile, the hit count of every source line the profile references.
Blocks are expanded across their line range, and a line covered by several blocks keeps the highest count — with `-covermode=count` overlapping blocks are possible, and a line is covered when any statement on it executed.
func ResolveProfilePath ¶
ResolveProfilePath converts a path as written in a cover profile into a slash-separated path relative to the module directory.
Profile paths are import paths, so the module path prefix is stripped. ok is false for entries that do not belong to this module, which happens when a profile is produced with -coverpkg or when Go reports a dependency.
Types ¶
type Options ¶
type Options struct {
// Root is the absolute scan root, used to make reported paths relative.
Root string
// WorkDir receives the intermediate .out profile.
WorkDir string
// Printer receives progress and diagnostics.
Printer *ui.Printer
}
Options configures a collection run.
type Result ¶
type Result struct {
Dir string
Rel string
ModulePath string
Files []model.FileCoverage
Warnings []string
Command string
ExitCode int
Output string
Err error
}
Result is the outcome for one Go module. A Result is always returned, even when the module failed: a failing `go test` still usually writes a partial profile, and cover100 reports what it can rather than discarding the module.