0

I use this command to download a package from GitHub; but the output surprising me, I want to install the package not to find the package under the GOPATH or GOROOT!

$ go get  github.com/golang/dep/cmd/dep

package github.com/golang/dep/cmd/dep: cannot find package "github.com/golang/dep/cmd/dep" in any of:
    /usr/local/Cellar/go/1.13/libexec/src/github.com/golang/dep/cmd/dep (from $GOROOT)
    /Users/mateuszhang/go/src/github.com/golang/dep/cmd/dep (from $GOPATH)

$ go get -u github.com/golang/dep/cmd/dep
package github.com/golang/dep/cmd/dep: cannot find package "github.com/golang/dep/cmd/dep" in any of:
    /usr/local/Cellar/go/1.13/libexec/src/github.com/golang/dep/cmd/dep (from $GOROOT)
    /Users/mateuszhang/go/src/github.com/golang/dep/cmd/dep (from $GOPATH)

my env

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mateuszhang/Library/Caches/go-build"
GOENV="/Users/mateuszhang/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH=":/Users/mateuszhang/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_t/b4m17gg13x1d_s9dpkp65bfsb9ckh4/T/go-build928907869=/tmp/go-build -gno-record-gcc-switches -fno-common"
1
  • Start by deleting you Go installation and install the official version from the official website according to the official installation instructions. Second: You seem to operate in modules modes: Turn it off with GO111MODULE=off. Commented Sep 5, 2019 at 4:19

1 Answer 1

3

You may need to set env var $GO111MODULE to on. You can do it by adding export GO111MODULE=on at the end of your bash profile file (i.e, ~/.bashrc or ~/.profile).

Want to install dep? Run:

go get -u github.com/golang/dep/cmd/dep

Want to install from source? Run:

go get -d -u github.com/golang/dep
cd $(go env GOPATH)/src/github.com/golang/dep
DEP_LATEST=$(git describe --abbrev=0 --tags)
git checkout $DEP_LATEST
go install -ldflags="-X main.version=$DEP_LATEST" ./cmd/dep
git checkout master
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.