Go 1.6, gom and vendor packages
Closed this issue ยท 24 comments
Hi @mattn
I noticed that using go1.6, gom install
places all vendor packages in a vendor
folder (rather than _vendor
), which I understand it's now the Go1.6 default location.
Within the vendor
folder, gom places my all the vendor modules outside the src
directory, which is not created anymore. When I try to build my go project, an error is thrown since go expects my vendor modules to live in vendor/src/github.com/etc
rather than vendor/github.com/etc
Is this an issue with gom, go1.6 or my current set up?
Thanks!
do you set GO15VENDOREXPERIMENT?
when I set GO15VENDOREXPERIMENT
the src
folder is created within _vendor
. All vendor packages are correctly placed and gom compiles just fine.
Here is a part to check versions of go.
Is this your expected?
Lines 69 to 77 in 183c76e
Sorry I don't still understand what is your issue.
Hi
Thin issue about go1.6 and go1.7 with gom are expecting to find dependencies source in $PROJECT/vendor/src/
but they are actually in $PROJECT/vendor/
@laysakura could you handle this issue?
Same problem here, my workaround:
cd vendor
ln -s ../vendor src
cd ..
gom build
The problem is basically this:
Building mcatalog...
src/mcatalog/main.go:6:2: cannot find package "github.com/Sirupsen/logrus" in any of:
/usr/local/Cellar/go/1.6.2/libexec/src/github.com/Sirupsen/logrus (from $GOROOT)
/Users/foobar/pg/mcatalog/vendor/src/github.com/Sirupsen/logrus (from $GOPATH)
/Users/foobar/pg/mcatalog/src/github.com/Sirupsen/logrus
/Users/foobar/pg/mcatalog/src/github.com/Sirupsen/logrus
It only happens with Golang >= 1.6
I think this is related to the fact that GOVENDOREXPERIMENT thingy only works if your project is in GOPATH/src
- if the project is outside GOPATH or GOPATH has been manually set to root of the project tree - there are several things that can go wrong.
To workaround this problem, I ended up changing my project layout to be exactly same as a valid GOPATH
. So in this case:
~> export GOPATH=`pwd`
~> tree .
|-- src/
|-- mcatalog/
|-- mcatalog/Gomfile (moved the Gomfile here from root of the project)
And ran the command gom install
via cd src/mcatalog && gom install
. This installs the dependencies in src/mcatalog/vendor
directory and now it works.
What version of go do you use ?
Go 1.6.3
Go 1.6 doesn't require GO15VENDOREXPERIMENT for vendoring. Do you set GO15VENDOREXPERIMENT ?
No no, it doesn't. What I mean is - GO15VENDOREXPERIMENT is automatically enabled in Go 1.6, but loading of dependencies from vendor
only works if project is in $GOPATH/src/
and vendorized dependencies are in $GOPATH/src/<project_name>/vendor
.
Previously - What I was doing is , my project layout used to be:
# I am in root of project and GOPATH being set to current directory
~> export GOPATH=`pwd`
~> tree .
|---- Gomfile
|---- _vendor/
|---- src/
|---- mcatalog/ (This is where my actual go files are)
|---- docs
But above directory layout no longer works because with go-1.6 vendored dependencies should be located in $GOPATH/src/project_name/vendor
So the new layout that works is:
# I am in root of project and GOPATH being set to current directory
~> export GOPATH=`pwd`
~> tree .
|---- src/
|---- mcatalog/ (This is where my actual go files are)
|---- mcatalog/Gomfile
|---- mcatalog/vendor/
|---- docs
And I am running gom install
by cd src/mcatalog && gom install
.
So all in all, I don't think this is particularly a bug in Gom, it is just that things have changed with go1.6.
Maybe most of users who have an issue about this, I guess they have same confusing. Thanks for your explaining!
I've hit the same issue.
I found curious behaviour like as follows:
During gom install
, vendor directory contains src
.
% ls vendor
src
But finishing gom install
, src directory has gone:
% ls vendor
github.com pkg
Is this behaviour is intentional?
plesae let me known your go version and whether you set $GOVENDOREXPERIMENT ?
I have been using gom
with Go-1.7 without problems. The only thing to remember is directory structure I explained above.
@egorsmkv try this repository
https://github.com/mattn/go-gom-example
$ go get -d github.com/mattn/go-gom-example
$ cd /path/to/your/gopath/src/github.com/mattn/go-gom-example
$ gom install
$ ls -1 vendor
github.com
pkg
@mattn I get this error:
src/utils/test.go:3:8: cannot find package "github.com/satori/go.uuid" in any of:
/home/egor/Tools/GoRoot/src/github.com/satori/go.uuid (from $GOROOT)
/home/egor/bolvanka/code/vendor/src/github.com/satori/go.uuid (from $GOPATH)
/home/egor/bolvanka/code/src/github.com/satori/go.uuid
/home/egor/Tools/GoPath/src/github.com/satori/go.uuid
Why is he trying to use the src folder?
go-gom-example doesn't use github.com/satori/go.uuid.
Okay. I get this error with go-go-example:
~/b/t/go-gom-example *master โ gom build
suddendeath.go:6:2: cannot find package "github.com/mattn/go-runewidth" in any of:
/home/egor/Tools/GoRoot/src/github.com/mattn/go-runewidth (from $GOROOT)
/home/egor/bolvanka/t/go-gom-example/vendor/src/github.com/mattn/go-runewidth (from $GOPATH)
/home/egor/bolvanka/t/go-gom-example/src/github.com/mattn/go-runewidth
/home/egor/Tools/GoPath/src/github.com/mattn/go-runewidth
gom: exit status 1
You need to do gom install
at the first.
Done:
~/b/t/go-gom-example *master โ gom install
downloading github.com/mattn/go-runewidth
downloading github.com/daviddengcn/go-colortext
~/b/t/go-gom-example *master โ ls vendor/
github.com/ pkg/
~/b/t/go-gom-example *master โ gom build
suddendeath.go:6:2: cannot find package "github.com/mattn/go-runewidth" in any of:
/home/egor/Tools/GoRoot/src/github.com/mattn/go-runewidth (from $GOROOT)
/home/egor/bolvanka/t/go-gom-example/vendor/src/github.com/mattn/go-runewidth (from $GOPATH)
/home/egor/bolvanka/t/go-gom-example/src/github.com/mattn/go-runewidth
/home/egor/Tools/GoPath/src/github.com/mattn/go-runewidth
gom: exit status 1
Because you doesn't do as my said.
you MUST get go-gom-example on GOPATH.