出现错误“无法下载,$ GOPATH未设置”,但我有它 [英] Got error "cannot download, $GOPATH not set," yet I have it set
本文介绍了出现错误“无法下载,$ GOPATH未设置”,但我有它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ echo $ GOPATH&& ls -r $ GOPATH
/home/cyrus/.go
src pkg bin
$ echo $ GOROOT&& ls $ GOROOT
/ usr / local / go
api作者bin贡献者doc favicon.ico include lib LICENSE misc PATENTS pkg README robots.txt src test VERSION
为什么我在执行操作时仍然遇到错误:
$ go获取code.google.com/p/go-tour/gotour
包code.google.com/p/go-tour/gotour:无法下载,未设置$ GOPATH。有关详细信息,请参阅:go help gopath
解决方案
一个像这样的变量:
GOPATH = $ HOME / go
它不会被导出到任何子流程。它只适用于该过程。如果您想将其导出到子流程,请使用 export
:
导出GOPATH
您也可以合并赋值和导出:
export GOPATH = $ HOME / go
However when I have already set it. I've even created sub directories which I don't know if necesary:
$ 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
Why do I still get the error when I do:
$ 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
解决方案
If you set a variable like this:
GOPATH=$HOME/go
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屋!
查看全文