- Run
install.bat
on windows orinstall.sh
on linux and osx.
This creates a go
directory with the golang distribution with an altered go
executable.
- Copy the
go
directory wherever you want ($godir
) and add$godir/bin
to yourPATH
.
You can then use go without setting GOROOT
, GOPATH
or GOBIN
.
The original go executable is replaced with a wrapper that sets those variables for the process only, and then calls the real go executable (renamed _go
).
GOROOT
is deduced from the location of the go executable in the PATH
.
For the GOPATH
, it looks for a directory called src
, starting from the current directory and then looking up. If it can't find any, the current directory is used.
GOBIN
is set to $GOPATH/bin
.