go install always attempts to use GOROOT and GOPATH is not listed under go env

前端 未结 4 1527
死守一世寂寞
死守一世寂寞 2020-12-31 13:19

I\'m having a quite frustrating problem with the GOPATH, which, despite being set in .profile, is not appearing when invoking go env,

4条回答
  •  醉酒成梦
    2020-12-31 14:00

    I think it's quite clear that go install everything in your GOTOOLDIR, GOTOOLDIR is also related with GOROOT:

    Yours: GOROOT="/usr/lib/go"

    According to Document:

    Install the Go tools

    The Go binary distributions assume they will be installed in /usr/local/go (or c:\Go under Windows), but it is possible to install them in a different location. If you do this, you will need to set the GOROOT environment variable to that directory when using the Go tools.

    For example, if you installed Go to your home directory you should add the following commands to $HOME/.profile:

    export GOROOT=$HOME/go

    export PATH=$PATH:$GOROOT/bin

    Windows users should read the section about setting environment variables under Windows.

    You should follow these steps to change your GOROOT, instead of GOPATH, then everything should work.

    If it's not work, change GOTOOLDIR as well.

提交回复
热议问题