Install Go (Golang)

Go is a programming language created by Google.

ref:
https://golang.org/

Installation

on Ubuntu:

$ sudo apt-get install -V golang

# or

$ wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
$ tar -C /usr/local -xzf go1.10.1.linux-amd64.tar.gz
$ vim /etc/profile
export PATH=$PATH:/usr/local/go/bin

$ which go

on macOS:

$ brew install go

$ go env
GOCACHE="/Users/vinta/Library/Caches/go-build"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vinta/go"
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
...

ref:
https://golang.org/dl/

Environment Variables

  • GOPATH is your workspace.
    • go get fetches source code and puts them into $GOPATH/src.

ref:
https://golang.org/doc/code.html