I noticed that my coverage reports were including mock packages.
To get rid of this instead of running
go test like this:
go test -race -coverpkg=./... -coverprofile allcoverage1.10rc.out ./...
I am now running it like this:
CVPKG=$(go list ./... | grep -v mocks | tr '\n' ',') go test -race -coverpkg $CVPKG -coverprofile allcoverage1.10rc.out ./...
go list ./... lists all packages in my project; we pipe that through
grep -v mocks to exclude mocks; we then pipe that output to
tr '\n' ',' to replace newlines (each package is listed on a new line) with commas. The comma separated list of all packages excluding mocks is then passed to
The resulting coverage report includes all non-test packages in my project except for mocks.