Golang 1.5供应商 – 找不到包装

前端之家收集整理的这篇文章主要介绍了Golang 1.5供应商 – 找不到包装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
尝试使用版本1.5并使用GO15VENDOREXPERIMENT =“1”在go lang中构建我的项目,以确保我在本地查找供应商.

我的结构是:

  1. apps_api
  2. main.go
  3. build.sh
  4. src
  5. controllers
  6. models
  7. views
  8. vendor
  9. github.com
  10. golang.org
  11. .....

build.sh包含

  1. export GO15VENDOREXPERIMENT="1"
  2. export GOPATH=`pwd`
  3. go build .

控制器文件示例

  1. import (
  2. "models"
  3. "views"
  4.  
  5. "github.com/gin-gonic/gin"
  6. )

但我得到很多错误,说没有找到包装,请参阅下面的例子

  1. src/controllers/app-versions.go:10:2: cannot find package "github.com/asaskevich/govalidator" in any of:
  2. /Users/ereeve/.gvm/gos/go1.5/src/github.com/asaskevich/govalidator (from $GOROOT)
  3. /Users/ereeve/Documents/gocode/src/apps_api/src/github.com/asaskevich/govalidator (from $GOPATH)
  4.  
  5. src/controllers/index.go:4:2: cannot find package "github.com/chnlr/baseurl" in any of:
  6. /Users/ereeve/.gvm/gos/go1.5/src/github.com/chnlr/baseurl (from $GOROOT)
  7. /Users/ereeve/Documents/gocode/src/apps_api/src/github.com/chnlr/baseurl (from $GOPATH)

如果我将这些行添加到我的build.sh文件中它将构建,但我不想使用go get因为我在我的项目中使用本地供应商的1.5以避免依赖.

  1. # go get github.com/gin-gonic/gin
  2. # go get github.com/go-sql-driver/MysqL
  3. # go get github.com/rif/cache2go
  4. ....

我有什么想法我做错了吗?

IIRC,GO15VENDOREXPERIMENT仅在您正在构建的包在$GOPATH / src内时才有效,所以设置
  1. export GOPATH=`pwd`

你的build.sh使它失败.如果你把你的apps_api放在〜/ fakegopath / src /中并运行

  1. env GOPATH="${HOME}/fakegopath/src/" GO15VENDOREXPERIMENT="1" go build .

它应该工作.

猜你在找的Go相关文章