Skip to content

Instantly share code, notes, and snippets.

@ammario
Created September 2, 2016 16:27
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save ammario/8e802dc0595faaed241bad19f72eda5c to your computer and use it in GitHub Desktop.
Save ammario/8e802dc0595faaed241bad19f72eda5c to your computer and use it in GitHub Desktop.
golang test coverage html
#!/bin/bash
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
@mihailo-misic
Copy link

I like to use the following one-liner version as well:

go test -coverprofile=c.out && go tool cover -html=c.out

@zanuka
Copy link

zanuka commented Mar 1, 2018

👍

@AliAlhajji
Copy link

AliAlhajji commented Jun 2, 2018

When I run go tool cover -html=c.out in VS Code it returns this error:
Too many arguments
and when I run it in the windows terminal:
cover: open chtml.out: The system cannot find the file specified.

@wang371758198
Copy link

wang371758198 commented Jan 17, 2020

When I run go tool cover -html=c.out in VS Code it returns this error:
Too many arguments
and when I run it in the windows terminal:
cover: open chtml.out: The system cannot find the file specified.

go test -cover -coverprofile chtml.out
go tool conver -html chtml.out

@joebowbeer
Copy link

go tool conver -html chtml.out

go tool cover -html chtml.out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment