I’m trying out some Go examples and I started with a JSON parser and I wanted to add a dependency to a remote repository. I was under the assumption that the Go build process will pull the dependencies when I compile, but strangely it did not. Here is the error that I get!
main.go:8:9: cannot find package "github.com/spf13/viper" in any of:
/usr/local/Cellar/go/1.9.1/libexec/src/github.com/spf13/viper (from $GOROOT)
/Users/joe/Projects/Private/go-projects/src/github.com/spf13/viper (from $GOPATH)
I thought the Go build will resolve this for me. Won’t it do that? If I have 10 or even 100’s of those dependencies from remote, should I do a go get for each one of them? This is purely inefficient. I’m sure I’m doing something wrong or? Is there a way that Go downloads it automatically when doing a Go build?
At the time of compiling Go will not resolve its dependencies, you can use a dependency manager, such as “glide” : “http://glide.sh/” or “Go dep” : “https://github.com/golang/dep” or any other