简体   繁体   English

Golang,GOPATH 未设置错误

[英]Golang, GOPATH not set error

I am getting the following error when I am trying to run the go code:当我尝试运行 go 代码时出现以下错误:

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.任何帮助将不胜感激。

Well it is saying that your GOPATH is not set.好吧,这是说您的 GOPATH 未设置。 I would suggest taking a look at the Go docs to get that configured.我建议查看Go 文档以进行配置。

Set under the Windows: open cmd Windows下设置:打开cmd

C:\Users\zhg>set GOPATH=C:\PATH

C:\Users\zhg>echo %GOPATH%
>>> C:\PATH

Set under the Linux: open bash Linux下设置:打开bash

zhg@ubuntu:~$ export GOPATH=$HOME/path
zhg@ubuntu:~$ echo $GOPATH 
>>> /home/zhg/path

Looking all go environment: $ go env查看所有 go 环境: $ go env

Set forever, you need to edit the environment files.设置为永久,需要编辑环境文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM