When I try the following
go test -coverprofile=coverage.out
I get this coverage.out:
mode: set
_/Users/gert/Desktop/httx/auth.go:10.66,11.54 1 0
_/Users/gert/Desktop/httx/auth.go:11.54,13.89 2 0
_/Users/gert/Desktop/httx/auth.go:17.3,17.11 1 0
_/Users/gert/Desktop/httx/auth.go:13.89,16.4 2 0
_/Users/gert/Desktop/httx/auth.go:22.42,25.2 2 0
...
But when I then do
go tool cover -func=coverage.out
coverage.out doesn't seem to be correctly formatted?
cover: can't find "auth.go": cannot find package "_/Users/gert/Desktop/httx/" in any of:
/usr/local/Cellar/go/1.7.1/libexec/src/_/Users/gert/Desktop/httx (from $GOROOT)
/Users/gert/go/src/_/Users/gert/Desktop/httx (from $GOPATH)
EDIT: Note that go test -cover
works.
PASS
coverage: 29.7% of statements
ok _/Users/gert/Desktop/httx 0.015s
Your package /Users/gert/Desktop/httx/
is outside of your $GOPATH
which is /Users/gert/go
. Move the httx
package somewhere under your $GOPATH
and it will work fine. You could move it to /Users/gert/go/src/httx
or probably something like /Users/gert/go/src/github.com/your-github-name/httx
(assuming you use GitHub).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With