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

我已经设置了我的$ 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条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?