[英]Golang 1.5 vendors - Cannot find package
Trying to build my project in go lang using version 1.5 with GO15VENDOREXPERIMENT="1"
turned on to ensure I look for the vendors locally. 尝试使用版本1.5并使用GO15VENDOREXPERIMENT="1"
在go lang中构建我的项目,以确保我在本地查找供应商。
My structure is: 我的结构是:
apps_api
main.go
build.sh
src
controllers
models
views
vendor
github.com
golang.org
.....
build.sh contains build.sh包含
export GO15VENDOREXPERIMENT="1"
export GOPATH=`pwd`
go build .
controller file example 控制器文件示例
import (
"models"
"views"
"github.com/gin-gonic/gin"
)
But i get lots of errors saying package not found see below for exmaple 但我得到很多错误,说没有找到包装,请参阅下面的例子
src/controllers/app-versions.go:10:2: cannot find package "github.com/asaskevich/govalidator" in any of:
/Users/ereeve/.gvm/gos/go1.5/src/github.com/asaskevich/govalidator (from $GOROOT)
/Users/ereeve/Documents/gocode/src/apps_api/src/github.com/asaskevich/govalidator (from $GOPATH)
src/controllers/index.go:4:2: cannot find package "github.com/chnlr/baseurl" in any of:
/Users/ereeve/.gvm/gos/go1.5/src/github.com/chnlr/baseurl (from $GOROOT)
/Users/ereeve/Documents/gocode/src/apps_api/src/github.com/chnlr/baseurl (from $GOPATH)
If i add these lines into my build.sh file it will build, but I don't want to use go get because I am using go 1.5 with the vendors locally inside my project to avoid dependancies. 如果我将这些行添加到我的build.sh文件中它将构建,但我不想使用go get因为我在我的项目中使用本地供应商的1.5以避免依赖。
# go get github.com/gin-gonic/gin
# go get github.com/go-sql-driver/mysql
# go get github.com/rif/cache2go
....
Any ideas what I am doing wrong? 我有什么想法我做错了吗?
IIRC, GO15VENDOREXPERIMENT
will work only if the package you're building is inside $GOPATH/src
, so setting IIRC, GO15VENDOREXPERIMENT
仅在您正在构建的包在$GOPATH/src
内$GOPATH/src
,所以设置
export GOPATH=`pwd`
in your build.sh
makes it fail. 你的build.sh
使它失败。 If you put your apps_api
inside say ~/fakegopath/src/
and run 如果你把你的apps_api
放在~/fakegopath/src/
并运行
env GOPATH="${HOME}/fakegopath/src/" GO15VENDOREXPERIMENT="1" go build .
it should work. 它应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.