Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does go get install packages?

Tags:

homebrew

go

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.

like image 857
Liron Yahdav Avatar asked May 31 '18 21:05

Liron Yahdav


People also ask

Where do go packages get installed?

All downloaded modules are cached locally in your $GOPATH/pkg/mod directory by default. If you import a package to your project without downloading it first using go get , the latest tagged version of the module providing that package will be installed automatically and added to your go.

Where are go packages installed by default?

By default, Go will be installed in /usr/local/go .

How do packages work in go?

Go programs are organized into packages. A package is a collection of source files in the same directory that are compiled together. Functions, types, variables, and constants defined in one source file are visible to all other source files within the same package. A repository contains one or more modules.

Where Are go files stored?

It defaults to a directory named go inside your home directory, so $HOME/go on Unix, $home/go on Plan 9, and %USERPROFILE%\go (usually C:\Users\YourName\go ) on Windows.


1 Answers

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.

like image 142
Liron Yahdav Avatar answered Oct 17 '22 08:10

Liron Yahdav