Do not allow dependency in vendor directory

I run go1.6 and get the following error when running "go build" in GOPATH (/ Users / bweidlich / Projects / go)

main.go:6:2: cannot find package "github.com/spf13/viper" in any of: /usr/local/go/src/github.com/spf13/viper (from $GOROOT) /Users/bweidlich/Projects/go/src/github.com/spf13/viper (from $GOPATH) 

Project Structure:

 bin/ glide.lock glide.yaml go.iml logs/ main.go pkg/ src/ vendor/ github.com/ deckarep/gosx-notifier spf13/viper gizak/termui 

main.go

 package main import ( "fmt" "github.com/gizak/termui" <--- doesn't resolve "github.com/spf13/viper" <--- doesn't resolve "log" "bweidlich/dash" "net/http" "os" "os/exec" "time" ) 
+6
source share
1 answer

Your main.go file must be inside the workspace (i.e. inside the gopath) for its dependencies to be sold. As a test, try placing your main.go inside a fake path and see if any found fingerprints are found:

 $GOPATH/src/ example.com/ main.go vendor/ github.com/ spf13/viper/ gizak/termui/ 

In general, you do not want to store any code in your gopath outside its src root directory. That is, you need an echo structure that go get will use when creating directories.

+5
source

All Articles