Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
golang test coverage html
#!/bin/bash
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
@mihailo-misic

This comment has been minimized.

Copy link

@mihailo-misic mihailo-misic commented Oct 16, 2017

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

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

This comment has been minimized.

Copy link

@zanuka zanuka commented Mar 1, 2018

👍

@AliAlhajji

This comment has been minimized.

Copy link

@AliAlhajji 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

This comment has been minimized.

Copy link

@wang371758198 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

This comment has been minimized.

Copy link

@joebowbeer joebowbeer commented Feb 1, 2021

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