[英]Golang, GOPATH not set error
當我嘗試運行 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)
任何幫助將不勝感激。
好吧,這是說您的 GOPATH 未設置。 我建議查看Go 文檔以進行配置。
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
設置為永久,需要編輯環境文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.