dqqs64238 2017-05-25 18:52
浏览 810
已采纳

当“ go env”显示设置正确时,为什么“ go get”找不到$ GOPATH?

I'm attempting to get go version go1.6.4 darwin/amd64 installed on my Macbook Pro.

I can't seem to download remote packages with 'go get' despite having the $GOPATH set. $ go env

GOARCH="amd64"  
GOHOSTARCH="amd64"  
GOHOSTOS="darwin"  
GOOS="darwin"  
GOPATH="/Users/Bryan/go"  
GORACE=""  
GOROOT="/usr/local/go"  
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"  
GO15VENDOREXPERIMENT="1"  
CC="clang"  
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"  
CXX="clang++"  
CGO_ENABLED="1"  

$ ls /Users/Bryan/go

total 24  
drwxr-xr-x   6 Bryan  staff   204 May 23 12:13 .  
drwxr-xr-x+ 73 Bryan  staff  2482 May 25 11:20 ..  
-rw-r--r--@  1 Bryan  staff  8196 May 24 15:11 .DS_Store  
drwxr-xr-x  32 Bryan  staff  1088 Mar 28 14:21 bin  
drwxr-xr-x   3 Bryan  staff   102 Mar 28 14:21 pkg  
drwxr-xr-x  10 Bryan  staff   340 May 25 11:18 src  

Bryan@Bryans-MacBook-Pro Thu May 25 12:23:24 ~/go/src/skincarereview
$ sudo go get

Password:  
package google.golang.org/appengine: cannot download, $GOPATH not set. For more details see: go help gopath  
package google.golang.org/appengine/datastore: cannot download, $GOPATH not set. For more details see: go help gopath
  • 写回答

1条回答 默认 最新

  • dragon188199 2017-05-25 18:56
    关注

    Your $GOPATH is set in your user $PATH, but you are envoking go get using sudo which has its own $PATH different from yours.

    To illustrate, try sudo go env and you will see the difference.

    You probably shouldn't be using sudo go get anyway though.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件