Differential Coverage
In his latest article Russ Cox explains the concept of using Differential Coverage for Debugging.
It's a clever approach using the difference of the coverage output between two test runs, to directly highlight the lines of code that contributed to a bug.
# collect coverage of a passing test run (skip the failing test) go test -coverprofile=c1.prof -skip='TestAddSub$' # collect coverage of a failing test run (run the failing test only) go test -coverprofile=c2.prof -run='TestAddSub$' # calculate the coverage difference between the runs (so only the code of the failing test gets highlighted) (head -1 c1.prof; diff c[12].prof | sed -n 's/^> //p') >c3.prof # display the code in a web browser (green/covered code did contribute to the failing test) go tool cover -html=c3.prof