错误“无法下载,未设置$ GOPATH." [英] Error "cannot download, $GOPATH not set."

查看:27
本文介绍了错误“无法下载,未设置$ GOPATH."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置:

看看我的配置:

$ echo $GOPATH && ls -r $GOPATH
/home/cyrus/.go
src  pkg  bin

$ echo $GOROOT && ls $GOROOT
/usr/local/go
api  AUTHORS  bin  CONTRIBUTORS  doc  favicon.ico  include  lib  LICENSE  misc  PATENTS  pkg  README  robots.txt  src  test  VERSION

您可以看到我已经为 $ GOPATH 设置了路径.另外,我创建了可能不需要的子目录.

You can see that I've set a path for $GOPATH. In addition, I've created subdirectories that I may not need.

问题:

为什么以下命令会生成此错误消息?

Why does the following command generate this error message?

$ go get code.google.com/p/go-tour/gotour                                                                                                               
package code.google.com/p/go-tour/gotour: cannot download, $GOPATH not set. For more details see: go help gopath

推荐答案

如果设置这样的变量:

GOPATH=$HOME/go

它不会导出到任何子流程.它仅适用于该过程.如果要将其导出到子流程,请使用 export :

It won't be exported to any subprocesses. It's only available to that process. If you want to export it to subprocesses, use export:

export GOPATH

您还可以结合分配和导出:

You can also combine the assignment and export:

export GOPATH=$HOME/go

这篇关于错误“无法下载,未设置$ GOPATH."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆