OS Manuals

/usr/bin/cover

standalone go tool cover

From go-1.24-cover 1.24.13-r4 (enterprise-packages), captured 2026-11-08 by running cover --help (exit 2). permalink

Usage of 'go tool cover':
Given a coverage profile produced by 'go test':
	go test -coverprofile=c.out

Open a web browser displaying annotated source code:
	go tool cover -html=c.out

Write out an HTML file instead of launching a web browser:
	go tool cover -html=c.out -o coverage.html

Display coverage percentages to stdout for each function:
	go tool cover -func=c.out

Finally, to generate modified source code with coverage annotations
for a package (what go test -cover does):
	go tool cover -mode=set -var=CoverageVariableName \
		-pkgcfg=<config> -outfilelist=<file> file1.go ... fileN.go

where -pkgcfg points to a file containing the package path,
package name, module path, and related info from "go build",
and -outfilelist points to a file containing the filenames
of the instrumented output files (one per input file).
See https://pkg.go.dev/cmd/internal/cov/covcmd#CoverPkgConfig for
more on the package config.

Flags:
  -V	print version and exit
  -func string
    	output coverage profile information for each function
  -html string
    	generate HTML representation of coverage profile
  -mode string
    	coverage mode: set, count, atomic
  -o string
    	file for output
  -outfilelist string
    	file containing list of output files (one per line) if -pkgcfg is in use
  -pkgcfg string
    	enable full-package instrumentation mode using params from specified config file
  -var string
    	name of coverage variable to generate (default "GoCover")

  Only one of -html, -func, or -mode may be set.
Options (8)
OptionDescriptionSource
-Vprint version and exithelp
-func stringoutput coverage profile information for each functionhelp
-html stringgenerate HTML representation of coverage profilehelp
-mode stringcoverage mode: set, count, atomichelp
-o stringfile for outputhelp
-outfilelist stringfile containing list of output files (one per line) if -pkgcfg is in usehelp
-pkgcfg stringenable full-package instrumentation mode using params from specified config filehelp
-var stringname of coverage variable to generate (default "GoCover")help

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.