Go only looks in vendor directory if dependency is incorrect

629 Views Asked by At

Go only looks in my vendor directory if i spell the dependacy wrong. I used glide to add the vendor.

This import is spelled correctly

package goserver

import (
    "net/http"
    "fmt"
    "github.com/gorilla/mux"
)

The result of a correctly spelled dep. Go looks in 2 directories and does not look into vendor tree directory

myhost:goserver myuser$ go build main.go 
go-server/routers.go:6:2: cannot find package "_/Users/myuser/go/src/goserver/vendor/github.com/gorilla/mux" in any of:
    /usr/local/Cellar/go/1.9/libexec/src/_/Users/myuser/go/src/goserver/vendor/github.com/gorilla/mux (from $GOROOT)
    /Users/myuser/go/src/_/Users/myuser/go/src/goserver/vendor/github.com/gorilla/mux (from $GOPATH)

Import is spelled incorrectly

package goserver

import (
    "net/http"
    "fmt"
    "githubwwwww.com/gorilla/mux"
)

The result of a incorrectly spelled dep. Go looks into 3 directories and looks into vendor directory

 myhost:goserver myuser$ go build main.go 
    go-server/routers.go:6:2: cannot find package "githubwwwww.com/gorilla/mux" in any of:
        /Users/myuser/go/src/goserver/vendor/githubwwwww.com/gorilla/mux (vendor tree)
        /usr/local/Cellar/go/1.9/libexec/src/githubwwwww.com/gorilla/mux (from $GOROOT)
        /Users/myuser/go/src/githubwwwww.com/gorilla/mux (from $GOPATH)

Proof that gorrila/mux is there

myhost:goserver myuser$ ls /Users/myuser/go/src/goserver/vendor/github.com/gorilla/mux/
LICENSE         bench_test.go       context_gorilla_test.go context_native_test.go  mux.go          old_test.go     route.go
README.md       context_gorilla.go  context_native.go   doc.go          mux_test.go     regexp.go

Go env result

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/myuser/go/"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ty/vksmqd9x38vclbmpbnvnqwwh0000gp/T/go-build089246630=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
0

There are 0 best solutions below