I'm using go-1.7 in MacOS Sierra.
My project is inside my $GOPATH/src folder and has a vendor folder inside with all its dependencies.
and I'm using the dependencies like this inside my code:
import (
"github.com/google/go-github/github"
)
Now if I run go build
i get the message that all my dependencies I use could not be found inside the $GOROOT and $GOPATH on the other and adding "vendor" to my code is working:
import (
"vendor/github.com/google/go-github/github"
)
But as far as I understood it should be possible to to like in the first code snipped.
ah FYI there are no symlinks etc.
Ok found the problem:
My MacOS File System is Case Insensitive but it looks like the go tools cant handle that... fixed my $GOPATH and now it works like it should...
you could use echo $GOPATH
in your terminal to see your path of golang in my case is /home/gujarat/golang
. this is the default path without src
path.
So from here all your packages and dependencies are inside src
in $GOPATH
. for example here is 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 must have all the folder and dependencies copied in your src
folder. like github.com
and gopkg.in
these are the folder that must exist if in src
root.
and if you cant import your "github.com/google/go-github/github"
it means that your github.com
inside your src
doens't have this folder. hope it helps
I got this error and struggled for a while; I update to Go 1.8.3 and was using glide version 0.12.3; and my GOPATH was set as $PWD and glide was installing everything in ./vendor folder;
Finally got the error; THERE SHOULD BE a src folder under GOPATH and all your workspace should be under this src folder
It must be in the docs, and in dev machine I set it proper; but missed in Jenkins build