douduiwei2831 2013-04-06 04:09
浏览 338
已采纳

go install始终尝试使用GOROOT,而go env下未列出GOPATH

I'm having a quite frustrating problem with the GOPATH, which, despite being set in .profile, is not appearing when invoking go env, and does not appear to be affecting the go install target location.

I'm attempting to use go install to install packages, and am getting this error, which clearly shows that it is attempting to install in /usr/lib/go, rather than the intended directory of /home/me/dev/go.

$ go install github.com/songgao/colorgo
go install github.com/songgao/go.pipeline: mkdir /usr/lib/go/pkg/linux_386/github.com: permission denied

go env gives the following results.

$ go env
GOROOT="/usr/lib/go"
GOBIN=""
GOARCH="386"
GOCHAR="8"
GOOS="linux"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_386"
GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread"
CGO_ENABLED="1"

But it most certainly is set.

$ echo $GOPATH
/home/me/dev/go

Update: I have exported GOPATH in ~/.profile and sourced it, but I'm still having the same problem.

$ export GOPATH=/home/me/dev/go
$ go env
GOROOT="/usr/lib/go"
GOBIN=""
GOARCH="386"
GOCHAR="8"
GOOS="linux"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_386"
GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread"
CGO_ENABLED="1"

Update again: This problem has ceased since I upgraded to go1.1beta2. I'm not sure what was wrong, because GOPATH appeared to be set correctly, but it's all apparently working now.

  • 写回答

4条回答 默认 最新

  • dongwei8440 2013-04-06 04:16
    关注

    GOPATH and workspaces

    $ mkdir -p $HOME/dev/go/src
    $ mkdir -p $HOME/dev/go/bin
    

    In $HOME/.profile:

    export GOPATH=$HOME/dev/go:
    export PATH=$PATH:$HOME/dev/go/bin
    

    Then reboot or log out and log in.

    As soon as you have logged in, before anything else, run:

    $ env | grep -i '^GO'
    GOPATH=/home/me/dev/go
    $ cat $HOME/.profile
    

    What output do you get?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?