Golang,GOPATH未设置错误。

huangapple go评论66阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2016年3月31日 09:04:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/36322446.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定