suggest change


If you come from other programming languages you’re probably used to placing source code anywhere in the file system.

Go tools expect a certain layout of the source code.

GOPATH is the root of the workspace and contains the following folders:

Like the PATH environment variable, GOPATH is a list of directories separated with : (; on Windows).

Go looks into GOPATH directories for packages (libraries).

The go get tool downloads packages to the first directory in GOPATH.

Since Go 1.8, if GOPATH environment variable is not set, it defaults to $HOME/go on Unix/Linux and %USERPROFILE%/go on Windows.

Some tools assume that GOPATH only consists of a single directory.


The directory where go install and go get will place binaries after building main packages. Generally this is set to somewhere on the system PATH so that installed binaries can be run and discovered easily.


This is the location of your Go installation. It is used to find the standard libraries.

It is very rare to have to set this variable as Go embeds the build path into the toolchain. Setting GOROOT is needed if the installation directory differs from the build directory (or the value set when building).

See go env for a full list of environment variables.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents