Where does go get install packages?

Issue

I’ve been given instructions to run go get <some-remote-git-repo> which seems to succeed, but it’s not clear to me where the package was installed to so I can run an executable from it.

Per https://golang.org/doc/code.html#remote it seems it will be installed in $GOPATH/bin but $GOPATH isn’t defined in my shell (though the go get command seems to work fine). Go is installed via Homebrew.

Solution

I found the missing clue by running brew info go, which says:

==> Caveats
A valid GOPATH is required to use the `go get` command.
If $GOPATH is not specified, $HOME/go will be used by default:
  https://golang.org/doc/code.html#GOPATH

From that I found the executable in question at $HOME/go/bin.

Answered By – Liron Yahdav

Answer Checked By – Timothy Miller (GoLangFix Admin)

Leave a Reply

Your email address will not be published.