3

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
$
Senthil Kumaran
  • 54,681
  • 14
  • 94
  • 131
  • 1
    To GOBIN. Print its value with go env. – Volker Apr 13 '22 at 18:07
  • 1
    `go get` does not install any binaries, it updates `go.mod`. Outside a module it will print `'go get' is no longer supported outside a module.` – JimB Apr 13 '22 at 18:41
  • Possible duplicate of [How can I install a package with go get](https://stackoverflow.com/questions/30295146/how-can-i-install-a-package-with-go-get) – blackgreen Apr 13 '22 at 19:06

1 Answers1

3

The go get command 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 go 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'.
JimB
  • 104,193
  • 13
  • 262
  • 255