Download
$ wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
Unarchive it
$ VERSION=1.6.2
$ OS=linux
$ ARCH=amd64
$ sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
Update your shell profile
export PATH=$PATH:/usr/local/go/bin
ONLY if installing go
to a custom location:
export GOROOT=$HOME/go
Choose a path for your go
workspace and update your shell environment; for example
export GOPATH=$HOME/projects/go
export PATH=$PATH:$GOPATH/bin
In your workspace, create a directory for your user projects; for example
$ mkdir -p $GOPATH/src/github.com/subfuzion
Test your environment
$ cd $GOPATH/src/github.com/subfuzion
$ mkdir hello
$ cd hello
$ vi hello.go
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
$ go fmt hello.go
# or
$ go fmt .
$ go install github.com/subfuzion/hello
# or
$ go install .
$ hello
hello, world
Switching go
versions
Reference