You are not logged in.

#1 2016-04-29 12:29:37

stp002
Member
Registered: 2011-12-26
Posts: 44

Unable to install go tools(GOROOT path issue)

Hi, everyone
I installed Go programming language from arch packages, but I am unable to install the go tools(vt,godoc) with the go command.There seems to some ambiguity about the GOROOT path.I read this bug report https://bugs.archlinux.org/task/38597,but couldn't figure out how to set the paths properly. 
My go environment variables.

 GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/archy/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
        -----go command errors------
go get -u golang.org/x/tools/cmd/vet
package golang.org/x/tools/cmd/vet: cannot find package "golang.org/x/tools/cmd/vet" in any of:
        /usr/lib/go/src/golang.org/x/tools/cmd/vet (from $GOROOT)
        /home/archy/go/src/golang.org/x/tools/cmd/vet (from $GOPATH)
----------------------------------------------------
go get -u golang.org/x/tools/cmd/godoc
go install golang.org/x/tools/cmd/godoc: open /usr/lib/go/bin/godoc: permission denied
-----------------------------------------
Listing shows this:
>ls  /usr/lib/go/pkg/tool/linux_amd64
addr2line api asm cgo compile cover dist doc fix link nm objdump pack pprof trace vet yacc 

Would appreciate any help.
Thanks

Offline

#2 2016-05-01 10:02:10

ms
Member
From: Bandung, Indonesia
Registered: 2010-07-28
Posts: 88
Website

Re: Unable to install go tools(GOROOT path issue)

I am using Go from source not from package, so the following advice could be work or not in your environment.

Have you read the Go Getting Started? [1]

Do not forget to add `$GOROOT/bin` to your `$PATH`.

Basically, you set GOPATH for your workspace [2]. Workspace is the directory where Go will find your packages when "importing" in code. For example, you set GOPATH to "$HOME/go",

    $ export GOPATH=$HOME/go

and then set the Go binaries by,

    $ export PATH=$GOPATH/bin

If you working or using only on one workspace then you should set both of those environment on your `$HOME/.profile` or shell environment (`.zshenv`, in my case). Do not forget to logout of all session to make the PATH works.

[1] https://golang.org/doc/install
[2] https://golang.org/doc/code.html#Workspaces

Offline

Board footer

Powered by FluxBB