GO(Golang)供应商实验在mac osx上失败 [英] GO (Golang) vendor experiment failing on mac osx
问题描述
继承我的目录结构:
$ b在osx上执行go 1.6.2 $ b
/ project
/ application
main.go
other.go
/ vendor
/github.com
/ vendor_name
/ package_name
我将GOPATH设置为 / Users / me / project / application
但是,当我尝试运行任何go工具(例如build)时,它似乎正在寻找应用程序/ src
而不是 application / vendor
,得到很多这样的结果:
main.go:15:2:找不到包github.com/facebookgo/grace/gracehttp中的任何一个:
/usr/local/Cellar/go/1.6.2/ libexec / src / github.com / facebookgo / grace / gracehttp(from $ GOROOT)
/Users/me/project/application/src/github.com/facebookgo/grace/gracehttp(from $ GOPATH)
您可以e for go env输出供应商实验在默认情况下处于打开状态,因为它应该是它似乎不起作用:
GOARCH =amd64
GOBIN =
GOEXE =
GOHOSTARCH =amd64
GOHOSTOS =darwin
GOOS =达尔文
GOPATH = / Users / me / project / application
GORACE =/ usr / local / Cellar / go / 1.6.2 / libexec / pkg / tool / darwin_amd64
GO15VENDOREXPERIMENT =1
CC =clang
GOGCCFLAGS = - fPIC -m64 -pthread - fno-caret-diagnostics -Qunused-arguments -fmessage-length = 0 -fno-common
CXX =clang ++
CGO_ENABLED =1
现在,funkiness的来源可能是之前安装的宿醉。我已经安装了各种版本,一些通过gvm(去版本管理器),一些通过自制软件。所以我卸载了gvm和它安装的版本,也停止了与自制软件一起使用,并且使用自制软件重新安装了1.6.2。
go version output:
go版本go1.6.2达尔文/ amd64
$ b $
$ b <$ p
$ b
/ usr / local / bin / go
有什么想法可能在这里出错了,或者我只是误解了vendoring应该如何工作?
请告诉我,如果您需要更多信息,很高兴提供 它似乎正在寻找在应用程序/ src中
是,go正在寻找 $ GOPATH / src
,对于供应商
来源文件夹,您的来源和都是。
一切都应该在 $ GOPATH / src
供应商文件夹 仅可由目录树中的代码导入,该目录树以 vendor
。
但是它是源代码的一部分,因此应该在 $ GOPATH / src
下。
Having some trouble getting the go vendor experiment working with go 1.6.2 on osx.
Heres my directory structure:
/project
/application
main.go
other.go
/vendor
/github.com
/vendor_name
/package_name
I have my GOPATH set to /Users/me/project/application
However when I try to run any of the go tools (e.g build) it seems to be looking in application/src
rather than application/vendor
, getting lots of this:
main.go:15:2: cannot find package "github.com/facebookgo/grace/gracehttp" in any of:
/usr/local/Cellar/go/1.6.2/libexec/src/github.com/facebookgo/grace/gracehttp (from $GOROOT)
/Users/me/project/application/src/github.com/facebookgo/grace/gracehttp (from $GOPATH)
As you can see for go env output vendor experiment is on by default as it should be it just doesnt seem to work:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/project/application"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.6.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.6.2/libexec/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
Now, the source of the funkiness may be a hangover from previous go installations. I had installed various versions of go over time, some through gvm (go version manager) and some through homebrew. So I have uninstalled gvm and the versions of go it had installed, also unstalled go with homebrew and reinstalled just 1.6.2 using homebrew.
go version output:
go version go1.6.2 darwin/amd64
which go:
/usr/local/bin/go
Any ideas what may have gone wrong here, or am I perhaps just misunderstanding how vendoring should work?
P.S. Please elt me know if you need more info, happy to provide
it seems to be looking in application/src
Yes, go is looking in $GOPATH/src
, both for your sources and for vendor
sources folders.
Everything should be in $GOPATH/src
The vendor folder is meant to be importable only by code in the directory tree rooted at the parent of "vendor
".
But it is part of your sources, and as such, should be under $GOPATH/src
.
这篇关于GO(Golang)供应商实验在mac osx上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!