无法下载,$ GOPATH未设置 [英] cannot download, $GOPATH not set
问题描述
我想用去安装json2csv,去获取github.com/jehiah/json2csv
但我收到这个错误:
package github.com/jehiah/json2csv:无法下载,$ GOPATH未设置。有关更多详细信息,请参阅:go help go path
有关如何在MacOS上解决此问题的任何帮助? p>
[更新:自1.8起, GOPATH
默认为 $ HOME / go
,但如果您想了解 GOPATH
布局,自定义等等,您仍然可以发现它有用。]
官方Go网站讨论GOPATH以及如何铺设出工作区目录。
export GOPATH =$ HOME / your-workspace-dir /
- 在你的shell中运行它,然后将它添加到〜/ .bashrc
或等价物中,以便将来为你设置。 Go将在 src /
, bin /
和 pkg /
,那里的子目录。你需要把你自己的包放在 $ GOPATH / src
之下的某个地方,比如 $ GOPATH / src / github.com / myusername /
如果你想发布到GitHub。你也可以在你的 .bashrc
中使用 export PATH = $ PATH:$ GOPATH / bin
,这样你就可以运行在 $ GOPATH
下编译的程序。
Keith Rarick您可以设置笔记 GOPATH = $ HOME
将Go的 src /
, pkg /
和 bin /
目录下的homedir。这可能很好(例如,您的路径中可能已经有 $ HOME / bin
),但当然有些人会使用多个工作区等。
I want to install json2csv using go get github.com/jehiah/json2csv
but I receive this error:
package github.com/jehiah/json2csv: cannot download, $GOPATH not set. For more details see: go help go path
Any help on how to fix this on MacOS?
[Update: as of Go 1.8, GOPATH
defaults to $HOME/go
, but you may still find this useful if you want to understand the GOPATH
layout, customize it, etc.]
The official Go site discusses GOPATH and how to lay out a workspace directory.
export GOPATH="$HOME/your-workspace-dir/"
-- run it in your shell, then add it to ~/.bashrc
or equivalent so it will be set for you in the future. Go will install packages under src/
, bin/
, and pkg/
, subdirectories there. You'll want to put your own packages somewhere under $GOPATH/src
, like $GOPATH/src/github.com/myusername/
if you want to publish to GitHub. You'll also probably want export PATH=$PATH:$GOPATH/bin
in your .bashrc
so you can run compiled programs under $GOPATH
.
Optionally, via Rob Pike, you can also set CDPATH
so it's faster to cd
to package dirs in bash: export CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/golang.org/x
means you can just type cd net/html
instead of cd $GOPATH/src/golang.org/x/net/html
.
Keith Rarick notes you can set GOPATH=$HOME
to put Go's src/
, pkg/
and bin/
directories right under your homedir. That can be nice (for instance, you might already have $HOME/bin
in your path) but of course some folks use multiple workspaces, etc.
这篇关于无法下载,$ GOPATH未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!