warning: GOPATH set to GOROOT (/usr/local/go) has no effect

65,355 views
Skip to first unread message

empt...@gmail.com

unread,
Sep 14, 2014, 2:43:23 PM9/14/14
to golan...@googlegroups.com
Hi, 

I have extracted this file (go1.3.1.linux-amd64.tar.gz) to /usr/local. 

I have added only these environment variables to .bashrc

export GOPATH=/usr/local/go
export PATH=$PATH:$GOPATH/bin

When I type go version or any go command, I receive:

warning: GOPATH set to GOROOT (/usr/local/go) has no effect

When I type:

go env

I am informed

...
GOROOT="/usr/local/go"
...

Can anyone tell me how this GOROOT env is being set and how I can unset it?

Many Thanks

Aidy







Péter Szilágyi

unread,
Sep 14, 2014, 3:00:09 PM9/14/14
to empt...@gmail.com, golang-nuts
Hi,

  Leave GOROOT alone. It should either be unset, or set to the installation folder (correct in your case). On the other hand, the GOPATH should *not* point to the Go installation, but rather to your workspace (see https://golang.org/doc/code.html#GOPATH). Whenever you install some package with go get or go install, it will land within the GOPATH. That is why it warns you, that you most definitely do *not* want random packages from the internet to be dumped into your official installation.

  Create one or more folders where you'd like to develop Go code and set those as your GOPATH (note, if multiple are set, then go get will pull and install packages into the first).

Cheers,
  Peter

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Cheney

unread,
Sep 14, 2014, 6:05:35 PM9/14/14
to golan...@googlegroups.com
GOROOT is seto to /usr/local/go by default. That value is burnt into the binary you downloaded.

The error is you need to set GOPATH to a path that you own. I suggest export GOPATH=$HOME, although this is highly subject to personal taste.

Please read http://golang.org/doc/code.html for more information.

benson opisa

unread,
Dec 11, 2021, 6:02:22 PM12/11/21
to golang-nuts
thanks for this information.

Sadman Sakib

unread,
Jun 12, 2022, 12:45:23 AM6/12/22
to golang-nuts
Thanks for the info.
Reply all
Reply to author
Forward
0 new messages