Help us shape the future of Go! Take the 2026 Go Developer Survey

covmerge

command
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Command covmerge merges Go coverage profiles (as produced by `go test -covermode=atomic -coverprofile=...`) into a single deduplicated profile.

Every unit/integration/e2e CI job in this repo runs with a wide -coverpkg (all instrumented packages), so each profile it emits already contains a coverage block for every package under test -- including ones that specific job never exercised (recorded with a zero count). Naively concatenating profiles (`tail -n +2 "$f" >> coverage.out` for each file, as a plain `cat`-style merge would) therefore duplicates every block once per job. With ~6 jobs and ~200 covered packages that inflates the merged file enough to blow past Node's ~512MB string length limit when a downstream step reads it back with fs.readFileSync.

covmerge instead parses each line's block key -- everything before the trailing execution count -- and sums counts for duplicate keys, emitting exactly one line per block. This is the same merge semantics as the well-known gocovmerge tool, specialized to atomic/count-style profiles (the only mode this repo's CI produces) and implemented with the standard library only so it needs no extra go.mod dependency.

Profiles are read and merged line-by-line via bufio.Scanner, so memory use is proportional to the number of distinct coverage blocks in the codebase, not to the combined size of the input files.

Usage:

go run ./cmd/covmerge -o coverage.out unit-0-coverage.out unit-1-coverage.out ...

With no -o flag, the merged profile is written to stdout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL