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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With