Golang 1.5 Suppliers - Cannot Find Package

An attempt to create my project in go lang using version 1.5 with GO15VENDOREXPERIMENT="1" included to ensure that I am looking for suppliers locally.

My structure:

 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 a lot of errors saying that the package was 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 to my build.sh file, it will be created, but I do not want to use go get, because I use go 1.5 with providers locally inside my project to avoid dependencies.

 # 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'm doing wrong?

+6
source share
1 answer

IIRC, GO15VENDOREXPERIMENT will only work if the package you are building is inside $GOPATH/src , so installation

 export GOPATH=`pwd` 

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

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

he should work.

+8
source

All Articles