dqz84361326 2015-03-04 15:03 采纳率: 0%
浏览 1096
已采纳

我已经设置了我的$ GOPATH,但是它不起作用

$ sudo go get -u github.com/golang/lint/golint
package github.com/golang/lint/golint: cannot download, $GOPATH not set. For more details see: go help gopath

I have set my $GOPATH: (in ~/.bash_profile on my Mac) export GOPATH=$HOME/gocode

And my go env:

$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wildcat/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fno-common"
CXX="g++"
CGO_ENABLED="1"

What's the problem?

  • 写回答

2条回答 默认 最新

  • douzhi9921 2015-03-04 15:07
    关注

    The issue is that you are using sudo: it will use the root environment variable instead of the ones of your account.

    You shouldn't need to use sudo, as I mentioned in "How to set GOPATH in Mac OS X 10.10":

    • sudo has a default policy of resetting the Environment and setting a secure path
    • unless you use the more complex sudo -E bash -c 'go get github.com/golang/lint/golint'):

    For now, this should be enough:

    go get -u github.com/golang/lint/golint
    

    The OP adds a different go get command in the comments:

    go install golang.org/x/tools/cmd/cover: 
      open /usr/local/go/pkg/tool/darwin_amd64/cover: permission denied 
    

    That one would be using $GOTOOLDIR (set in your case to "/usr/local/go/pkg/tool/darwin_amd64")

    As documented in "Permission denied error for 'go.tools'", running sudo -s then the go get command should work.

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

报告相同问题?

悬赏问题

  • ¥15 freertos下使用外部中断失效
  • ¥15 输入的char字符转为int类型,不是对应的ascall码,如何才能使之转换为对应ascall码?或者使输入的char字符可以正常与其他字符比较?
  • ¥15 devserver配置完 启动服务 无法访问static上的资源
  • ¥15 解决websocket跟c#客户端通信
  • ¥30 Python调用dll文件输出Nan重置dll状态
  • ¥15 浮动div的高度控制问题。
  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题
  • ¥15 pic16F877a单片机的外部触发中断程序仿真失效
  • ¥15 Matlab插值拟合差分微分规划图论