Is gocov only supposed to work on code within GOPATH?
toli opened this issue · 1 comments
Apologies for a newbie question (i'm fairly new to Go)
Let's say i have code living in
~/dev/project/go_implementation/api
. This is not inside my GOPATH
which is set to be ~/dev/go
.
I can run go test
and it passes fine.
However, when i run the gocov test
tool, i get an error saying that
coverage: 40.9% of statements ok _/Users/toli/dev/project/go_implementation/api 0.009s error: can't find "main.go": cannot find package "_/Users/toli/dev/project/go_implementation/api" in any of: /usr/local/Cellar/go/1.4.2/libexec/src/_/Users/toli/dev/project/go_implementation/api (from $GOROOT) /Users/toli/dev/go/src/_/Users/toli/dev/project/go_implementation/api (from $GOPATH)
If i symlink the directory to be inside GOPATH and cd into it, things work:
~/dev/go/src/github.com/toli/project/go_implementation/api
So, the potential newbie question: can gocov
only run from inside the GOPATH?
That works fine for me on my laptop, but I can't get it to work with CircleCI so i'm hoping there's an easier workaround.
Sorry for the late answer @toli. Yes, I think so, gocov
looks for packages inside you $GOPATH
(or your $GOROOT
).
Please have a look at the official documentation: https://golang.org/doc/code.html#GOPATH