Where does go install the binaries of go get?

Issue

I wanted to install ginkgo command and I tried.

$ go get github.com/onsi/ginkgo/ginkgo
go: downloading golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
go: upgraded github.com/onsi/ginkgo v1.12.1 => v1.16.5

But I am not sure where the ginkgo command is installed.

Here is my environment.

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/senthilx/.cache/go-build"
GOENV="/home/senthilx/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/senthilx/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/senthilx/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1077100959=/tmp/go-build -gno-record-gcc-switches"

The command didn’t install ginkgo in my "GOPATH"

$ ls
pkg

$ find . -type f -name ginkgo
$

Solution

The go get is only used for updating module dependencies, it does not install any binaries. The ability to install main packages was deprecated in go1.17. Within a module the get command will show any changes made to the dependencies, as you can see by the output:

go: downloading golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
go: upgraded github.com/onsi/ginkgo v1.12.1 => v1.16.5

If you try to use go get outside of a module it will return the error:

go: go.mod file not found in current directory or any parent directory.
    'go get' is no longer supported outside a module.
    To build and install a command, use 'go install' with a version,
    like 'go install example.com/cmd@latest'
    For more information, see https://golang.org/doc/go-get-install-deprecation
    or run 'go help get' or 'go help install'.

Answered By – JimB

Answer Checked By – Mildred Charles (GoLangFix Admin)

Leave a Reply

Your email address will not be published.