Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Golang 1.5供应商-找不到软件包_Go - Fatal编程技术网

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

Golang 1.5供应商-找不到软件包,go,Go,尝试使用1.5版在go lang中构建我的项目,并启用GO15VENDOREXPERIMENT=“1”,以确保我在本地查找供应商 我的结构是: apps_api main.go build.sh src controllers models views vendor github.com golang.org ..... build.sh包含 export GO15VENDOREXPERIMENT=

尝试使用1.5版在go lang中构建我的项目,并启用
GO15VENDOREXPERIMENT=“1”
,以确保我在本地查找供应商

我的结构是:

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"
)
但我得到了很多错误,说包找不到见下面的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)
如果我将这些行添加到build.sh文件中,它将生成,但我不想使用go-get,因为我在项目中使用go 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中,它会失败。如果你把你的
应用程序\u api
放在里面,说
~/fakegopath/src/
然后运行

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

它应该可以工作。

你试过go-get-github.com/Asasakevich/govalidator吗?我使用go 1.5,所以我在vendor/github.com中有该文件,以避免使用go-get,然后在不同的环境中有不同的版本。谢谢,但我得到了以下信息:go:GOPATH条目不能以shell元字符“~”开头:“~/Documents/gocode/src/”-我是否需要显式填写GOPATH?请尝试将
~
替换为
${HOME}
。我现在得到($GOPATH未设置)?导出GO15VENDOREXPERITION=“1”导出GOPATH=“$HOME/Documents/gocode”开始生成。-试过{HOME}两个出口在同一行吗?在这种情况下,要么在每个export语句后添加分号(
export a=a;export B=B;echo$a$B
),要么像我的回答一样使用
env