GOPATH值设置 [英] GOPATH value setting

查看:224
本文介绍了GOPATH值设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装go1.3.1.windows-amd64.msi,安装后GOROOT是默认设置,我在PATH中找到了
D:\ Program \ Go \ bin,那么我使用'go get'命令创建一个GOPATH环境变体
,发生错误:

包github.com/coreos/etcd:无法下载,$ GOPATH不能设置为$ GOROOT。有关更多详细信息,请参阅:go help gopath



OS:windows 7



GOPATH会与GOROOT冲突吗? p>

如何设置这两个PATH值?

解决方案


  • GOROOT 必须引用您安装的文件夹

  • GOPATH 必须引用一个空的文件夹,该文件夹将是您的 工作区 ( src / pkg / bin)



在用户环境变量中添加这两个变量。

A go get github.com/coreos/etcd should:




  • 下载%GOPATH%/ src / github.com / coreos / etcd src 是为您创建)

  • %GOPATH%/ pkg / windows_amd64 pkg / 是为你创建的, windows_amd64 反映你的windows体系结构) go install 将$>
  • 安装到%GOPATH%/ bin bin / 也是为您创建的)



注意:使用Go 1.8+ 2017), GOPATH 可能会默认设置为(在Windows上)%USERPROFILE%/ go 。 >
在Linux上,它会是 $ HOME / go :请参阅 issue 17262


I'm install the go with the go1.3.1.windows-amd64.msi, after installation GOROOT is default setting, I found the D:\Programs\Go\bin in the PATH,then I create a GOPATH environment variant, when using the 'go get' command, error occurs:

package github.com/coreos/etcd: cannot download, $GOPATH must not be set to $GOROOT. For more details see: go help gopath

OS: windows 7

GOPATH will conflict with GOROOT?

How can I set these two PATH values?

解决方案

  • GOROOT must reference the folder where you installed GO
  • GOPATH must reference an empty folder which will be your workspace (src/pkg/bin for your projects)

Add those two variables in your user environment variables.

A go get github.com/coreos/etcd should:

  • download the sources in %GOPATH%/src/github.com/coreos/etcd (src is created for you)
  • compile it in %GOPATH%/pkg/windows_amd64 (pkg/ is created for you, windows_amd64 reflects your windows architecture)
  • with go install, install it in %GOPATH%/bin (bin/ is also created for you)

Note: with Go 1.8+ (Q2 2017), GOPATH might be set for you by default to (on Windows) %USERPROFILE%/go.
On Linux, it would be $HOME/go: see issue 17262.

这篇关于GOPATH值设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆