Skip to content
Latchkey

Go Coverage "no statements" - Fix Empty Coverage Results in CI

A coverage run produced an empty or misleading result. A -coverpkg pattern that matches no tested package, or a package with no executable statements, makes Go warn and report 0.0% or [no statements] - which can silently pass a coverage gate.

What this error means

A go test -cover run prints warning: no packages being tested depend on matches for pattern ..., or a package reports coverage: [no statements] / 0.0% of statements. The suite "passes" but covers nothing meaningful.

go test output
warning: no packages being tested depend on matches for pattern github.com/org/app/internal/...
ok  	github.com/org/app/cmd	0.012s	coverage: [no statements]

Common causes

A -coverpkg pattern that matches nothing tested

The packages named by -coverpkg are not imported by any package under test, so Go has nothing to instrument and warns.

A package with no executable statements

A package that is only declarations (constants, types, interfaces) reports [no statements] because there is nothing to cover.

How to fix it

Align -coverpkg with the tested packages

Point coverage at packages the tests actually import, or measure per-package coverage instead.

Terminal
go test -coverpkg=./... -coverprofile=cover.out ./...
go tool cover -func=cover.out

Treat the warning as a gate signal

  1. Decide whether the warned packages should be tested; if so, add tests that import them.
  2. Exclude declaration-only packages from coverage thresholds rather than counting them.
  3. Fail CI on the warning if empty coverage indicates a misconfigured gate.

How to prevent it

  • Keep -coverpkg patterns in sync with what your tests import.
  • Exclude declaration-only packages from coverage targets.
  • Inspect go tool cover -func output, not just the pass/fail.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →