go coverage tools
Install the
go test
Tool:bash go test -v
Generate Coverage Profile:
bash go test -coverprofile=coverage.out
View Coverage Report:
bash go tool cover -html=coverage.out
View Coverage in Terminal:
bash go tool cover -func=coverage.out
Exclude Files or Packages from Coverage:
bash go test -coverpkg=./... -coverprofile=coverage.out
Set Minimum Coverage Percentage:
bash go test -coverprofile=coverage.out -coverpkg=./... -covermode=count
Use
goconvey
for Real-time Coverage Updates:bash go get -u github.com/smartystreets/goconvey
Run
goconvey
for Real-time Coverage:bash goconvey
Use
gocov
for More Advanced Analysis:bash go get -u github.com/axw/gocov/gocov
Generate JSON Output with
gocov
:bash gocov test ./... | gocov report