Go comes with a terrific testing and coverage tool. Although all Go tools are well documented go tool cover -help I would suggest reading the cover article on the official Go blog . It has many examples, and I highly recommend it!
I have this function in my ~ / .bash_profile. (you can just paste it into the terminal to try it).
cover () { t="/tmp/go-cover.$$.tmp" go test -coverprofile=$t $@ && go tool cover -html=$t && unlink $t }
Then just cd to the project / package folder go and type cover . This opens a visual tool in the browser that shows you the verified and unverified code for each file in the current package. Very helpful team! I highly recommend that you find something that has not yet been 100% verified! Shown results for each file. From the drop-down list at the top left you can see the results for all files.
With this command you can also check the coverage of any package, for example:
cover fmt
The output in the terminal of this command:
ok fmt 0.031s coverage: 91.9% of statements
In addition to this, in your browser you will see that this tool displays in red all lines of code that are not covered by tests:

You can also just save the html coverage file and not open it in a browser. This is very useful in cases where your tests + coverage is performed by a CI tool like Jenkins. Thus, you can maintain coverage files from a central server, and the entire team will be able to see coverage results for each assembly.
Pavel Nikolov Dec 04 '14 at 1:00 a.m. 2014-12-04 01:00
source share