This is a creation in Article, where the information may have evolved or changed.
GOROOTGothe installation directory that points to the development package. From Go 1.0 the beginning, you do not have to display the GOROOT environment variables. The Windows installation package will be set up automatically and is installed GOROOT by default in C:\Go :
GOROOT=C:\Go\
In the *nix environment, download the Go installation package and unzip it in the /usr/local/ directory, then /usr/local/go/bin Add the PATH environment variables:
PATH=$PATH:/usr/local/go/bin
If the Go installation package is not installed in the default directory ( Windows for C:\Go , *nix for /usr/local/go ), you need to set it manually, for GOROOT example ( *nix ):
export GOROOT=$HOME/go
GOPATHThe Go project directory, containing src , pkg and bin three subdirectories are specified. This is the Go only environment variable that needs to display settings when the program is developed. When go get you download a Go third-party package by using a directory, it is also installed in this directory. Also, for convenience, remember to $GOPATH/bin add to the PATH environment variable:
export PATH=$PATH:$GOPATH/bin
In addition, according to the recommendation of this post, set a GoPATH sufficient.
Resources:
1. Easy Go programming Setup for Windows;
2. You don ' t need to set goroot, really;
3. How to Write Go Code;
4. Go Getting Started.