Vendor folder not used with 'go build'

I am using go-1.7 on MacOS Sierra.

My project is inside my $ GOPATH / src folder and has a vendor folder inside with all its dependencies.

and I use dependencies like this inside my code:

import ( "github.com/google/go-github/github" ) 

Now, if I run go build , I get a message saying that all my dependencies that I use cannot be found inside $ GOROOT and $ GOPATH on another, and adding "vendor" to my code works:

 import ( "vendor/github.com/google/go-github/github" ) 

But, as I understand it, it should be possible for the first code to be truncated.

ah FYI no symbolic links, etc.

+5
source share
3 answers

The problem is well detected:

My MacOS file system is case insensitive, but it looks like the go can can can not ... tool fixed my $ GOPATH and now it works as it should ...

+2
source

you can use echo $GOPATH in your terminal to see that your golang path in my case is /home/gujarat/golang . this is the default path without src path.

So, all your packages and dependencies are inside src in $GOPATH . for example, here are some packages that I used in my project.

 "fmt" "github.com/myproject/lol/src/config" // notice the first github.com "gopkg.in/redis.v4" // notice the gopkg.in "log" 

from the above package you should have the whole folder and dependencies copied in your src folder. e.g. github.com and gopkg.in , this is the folder that should exist if src root.

and if you cannot import your "github.com/google/go-github/github" , then your github.com inside your src does not have this folder. hope this helps

+1
source

I got this error and struggled for a while; I upgrade to Go 1.8.3 and used the slide version 0.12.3; and my GOPATH was installed as $ PWD, and glide installed everything in the folder. / vendor;

Finally, an error is received; SHOULD BE a src folder under GOPATH, and your entire workspace should be in this src folder

It should be in the documents, but in the dev machine I installed it correctly; but missed in jenkins compilation

0
source

Source: https://habr.com/ru/post/1261865/


All Articles