I'm working with build.Import to discover package dependencies and am having an issue where it find some packages in the vendor folder but not others. Specifically, golang/x packages. I have both oauth2 and tools in the vendor folder but it only finds oauth2 and instead finds the $GOPATH tools install. Both oauth2 and tools are installed in $GOPATH and vendor folder. tools is the only package that doesn't get found in vendor.
My code is
wd, _ := os.Getwd() // need to pass in wd as src directory to import otherwise it always find global installs
fmt.Println("ImportPath =", pkg.ImportPath)
fmt.Println("ImportPath =", pkg.ImportPath)
Here is my directory structure which also shows both oauth2 and tools installed in the vendor folder and the output of the above code.
drwxr-xr-x 4 travis staff 136 May 1 14:57 .
drwxr-xr-x 3 travis staff 102 May 1 13:39 ..
drwxr-xr-x 33 travis staff 1122 May 1 13:39 oauth2
drwxr-xr-x 24 travis staff 816 May 1 14:56 tools
Am I missing something?