duanchuang6978 2015-10-09 09:17
浏览 70
已采纳

Golang 1.5供应商-找不到软件包

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.

My structure is:

apps_api
   main.go
   build.sh
   src
      controllers
      models
      views
   vendor
      github.com
      golang.org
      .....

build.sh contains

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.

# 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?

  • 写回答

1条回答 默认 最新

  • dongroufan6846 2015-10-09 09:43
    关注

    IIRC, GO15VENDOREXPERIMENT will work only if the package you're building is inside $GOPATH/src, so setting

    export GOPATH=`pwd`
    

    in your build.sh makes it fail. If you put your apps_api inside say ~/fakegopath/src/ and run

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

    it should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度