英文:
Golang, GOPATH not set error
问题
当我尝试运行Go代码时,出现以下错误:
无法在以下任何位置找到包“github.com/drone/routes”:
/usr/local/Cellar/go/1.5.1/libexec/src/github.com/drone/routes(来自$GOROOT)
($GOPATH未设置)
非常感谢您的帮助。
英文:
I am getting the following error when I am trying to run the go code:
cannot find package "github.com/drone/routes" in any of:
/usr/local/Cellar/go/1.5.1/libexec/src/github.com/drone/routes (from $GOROOT)
($GOPATH not set)
Any help would be highly appreciated.
答案1
得分: 2
你的GOPATH未设置。我建议查看Go文档以进行配置。
英文:
Well it is saying that your GOPATH is not set. I would suggest taking a look at the Go docs to get that configured.
答案2
得分: 2
在Windows下设置:
打开命令提示符(cmd)
C:\Users\zhg>set GOPATH=C:\PATH
C:\Users\zhg>echo %GOPATH%
>>> C:\PATH
在Linux下设置:
打开终端(bash)
zhg@ubuntu:~$ export GOPATH=$HOME/path
zhg@ubuntu:~$ echo $GOPATH
>>> /home/zhg/path
查看所有Go环境:
$ go env
要永久设置,你需要编辑环境文件。
英文:
Set under the Windows:
open cmd
C:\Users\zhg>set GOPATH=C:\PATH
C:\Users\zhg>echo %GOPATH%
>>> C:\PATH
Set under the Linux:
open bash
zhg@ubuntu:~$ export GOPATH=$HOME/path
zhg@ubuntu:~$ echo $GOPATH
>>> /home/zhg/path
Looking all go environment:
$ go env
Set forever, you need to edit the environment files.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论