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.

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

报告相同问题?

悬赏问题

  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决