Locating Packages Installed by 'go get'
When using the go get command to install packages, it's crucial to know their installation location to access their executables. This article explores where packages are installed and provides a solution for users who encounter difficulties locating them.
According to the Go documentation, packages retrieved via go get are typically installed in $GOPATH/bin. However, this environment variable may not be explicitly defined in your shell. If $GOPATH is not set, Go will default to using $HOME/go as the installation directory.
The user in our case used Homebrew to install Go. By running brew info go, they discovered the following 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
This clue led them to search for the executable in $HOME/go/bin, where it was successfully located. Therefore, for Homebrew users who encounter missing $GOPATH issues, they should check the installation directory at $HOME/go/bin to find their installed packages.
The above is the detailed content of Where Do Go Packages Installed with 'go get' Go?. For more information, please follow other related articles on the PHP Chinese website!