尝试使用版本1.5并使用GO15VENDOREXPERIMENT =“1”在go lang中构建我的项目,以确保我在本地查找供应商.
我的结构是:
apps_api main.go build.sh src controllers models views vendor github.com golang.org .....
build.sh包含
export GO15VENDOREXPERIMENT="1" export GOPATH=`pwd` go build .
控制器文件示例
import ( "models" "views" "github.com/gin-gonic/gin" )
但我得到很多错误,说没有找到包装,请参阅下面的例子
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)
如果我将这些行添加到我的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 ....
我有什么想法我做错了吗?
IIRC,GO15VENDOREXPERIMENT仅在您正在构建的包在$GOPATH / src内时才有效,所以设置
export GOPATH=`pwd`
你的build.sh使它失败.如果你把你的apps_api放在〜/ fakegopath / src /中并运行
env GOPATH="${HOME}/fakegopath/src/" GO15VENDOREXPERIMENT="1" go build .
它应该工作.