In Go, when I import a dependency like:
import "github.com/spf13/viper"
Which directories will Go look into, and in which order?
Lookup order:
Run go help gopath
to learn more on how Go
search each directory.
A quick and easy way to see the search order and exact paths searched n a particular system is to run go build err
.
This produces output similar to this:
can't load package: package err: cannot find package "err" in any of:
C:\go\src\err (from $GOROOT)
\\FREENAS\Global Documents\Projects\Go\src\err (from $GOPATH)