Can't run go tool cover

1,493 views
Skip to first unread message

odownar...@gmail.com

unread,
Dec 3, 2014, 7:30:57 PM12/3/14
to golan...@googlegroups.com
I'm trying to profile my code however go test -cover always complains about cover not being available.
Upon further investigation "go tool cover" doesn't work either and asks me to run "go get ......etc".
Whenever I run go get ....., it doesn't print anything output and go tool cover still fails to work.

I've tried reinstalling go from source and from tarball.

go tool
go tool: no tool directory: open /usr/local/go/lib/gccgo/tool: no such file or directory


go list all | grep cover:

go env:
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oliver/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/lib/gccgo/tool"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"

On an a potentially related note, when trying go get code.google.com/p/go.tools/cmd/...
it seg faulted.


if I run go install golang.org/x/tools/cmd/cover
running cover instead of go tool cover seems to work although
I don't think this is intended behaviour? Is there something I have done wrong or
failed to do?

 

minux

unread,
Dec 4, 2014, 1:03:14 AM12/4/14
to odownar...@gmail.com, golang-nuts
On Wed, Dec 3, 2014 at 7:30 PM, <odownar...@gmail.com> wrote:
I'm trying to profile my code however go test -cover always complains about cover not being available.
Upon further investigation "go tool cover" doesn't work either and asks me to run "go get ......etc".
Whenever I run go get ....., it doesn't print anything output and go tool cover still fails to work.

I've tried reinstalling go from source and from tarball.

go tool
go tool: no tool directory: open /usr/local/go/lib/gccgo/tool: no such file or directory

go list all | grep cover:

go env:
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oliver/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/lib/gccgo/tool"
This is not right. It should be /usr/local/go/pkg/tool/linux_amd64 if using the gc toolchain.
It seems you're using a version go command that is built using gccgo.

Anyway, if you're using gccgo, then make that directory, as cover is supposed to install
into GOTOOLDIR instead of GOBIN or GOPATH/bin.

TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"

On an a potentially related note, when trying go get code.google.com/p/go.tools/cmd/...
it seg faulted.
It's possibly due to the fact the go command is compiled using gccgo and has some
version skew. 

Oliver Downard

unread,
Dec 4, 2014, 11:07:50 AM12/4/14
to minux, golang-nuts
Is there a way to change GOTOOLDIR to the correct path, I've tried export GOTOOLDIR=/usr/local/go/pkg/tool/linux_amd64 however go env still says that
GOTOOLDIR="/usr/local/go/lib/gccgo/tool". Or should I just create it as a directory and install the tools using go get?

minux

unread,
Dec 4, 2014, 4:16:27 PM12/4/14
to Oliver Downard, golang-nuts
On Thu, Dec 4, 2014 at 11:07 AM, Oliver Downard <odownar...@gmail.com> wrote:
Is there a way to change GOTOOLDIR to the correct path, I've tried export GOTOOLDIR=/usr/local/go/pkg/tool/linux_amd64 however go env still says that
GOTOOLDIR="/usr/local/go/lib/gccgo/tool". Or should I just create it as a directory and install the tools using go get?
No. GOTOOLDIR is embedded into the go/build package, and there is no way to override
that will an environment variable. You probably want to check whether you're accidentally
using a go command build by gccgo with gc first. I expect that will cause other problems
down the road. If you use the gc toolchain, use a go tool build by gc.

odownar...@gmail.com

unread,
Dec 4, 2014, 5:10:45 PM12/4/14
to golan...@googlegroups.com, odownar...@gmail.com
Thanks, I understand the problem. Would it be a good idea to just reinstall go entirely? 

Dave Cheney

unread,
Dec 4, 2014, 5:18:55 PM12/4/14
to golan...@googlegroups.com
I'd recommend that, just use the offical tarball from the golang.off website. Then you have all the tools you need preinstalled.

Make super sure you've purged all other installes on that machine, I suspect somehow you've picked up Ubuntu's gccgo-go package.

minux

unread,
Dec 4, 2014, 5:19:14 PM12/4/14
to Oliver Downard, golang-nuts
On Thu, Dec 4, 2014 at 5:10 PM, <odownar...@gmail.com> wrote:
Thanks, I understand the problem. Would it be a good idea to just reinstall go entirely? 
That's certainly the easiest way to solve the problem. But remember to delete the old
GOROOT entirely before installing new one.
Reply all
Reply to author
Forward
0 new messages