Home  >  Article  >  Backend Development  >  Where are Go packages installed when using `go get` without a defined `$GOPATH`?

Where are Go packages installed when using `go get` without a defined `$GOPATH`?

Linda Hamilton
Linda HamiltonOriginal
2024-11-19 03:41:02785browse

Where are Go packages installed when using `go get` without a defined `$GOPATH`?

Locating the Installation Directory for Packages Installed with go get

In this query, the user expresses confusion about the installation location of packages downloaded using go get, despite perceiving a successful installation process. The question arises from a lack of defined $GOPATH in the user's shell and the installation of Go through Homebrew.

To solve this predicament, the user consulted the documentation at https://golang.org/doc/code.html#remote, suggesting that the default installation path is $GOPATH/bin. However, the absence of $GOPATH in the user's environment presented an obstacle.

The solution was discovered by examining the output of brew info go, which revealed a crucial caveat:

==> 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

Consequently, the user identified the executable in question at $HOME/go/bin, resolving the location ambiguity.

The above is the detailed content of Where are Go packages installed when using `go get` without a defined `$GOPATH`?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn