This is a creation in Article, where the information may have evolved or changed.
0. Environment: Ubuntu16.04 64-bit
1. Download the installation package, Address: https://golang.org/dl, take version 1.8 as an example, download go1.8.linux-amd64.tar.gz
2. Unzip to/usr/local (official recommendation)
3. Add environment variables at the end of the ~/.BASHRC file:
Export gopath=~/share/go_workspaceexport goroot=/usr/local/goexport GOBIN= $GOROOT/bin/ Export PATH= $PATH: $GOBIN
The value of Goroot is the root directory of Go, and the value of Gopath is the workspace directory
Then execute the source ~/.BASHRC load environment variable into memory
4. Use Go env to view the current GO environment variables
Reference http://blog.csdn.net/weiyuefei/article/details/51160347
5. First program Hello World:
1 Package Main 2 3 " FMT " 4 5 Func Main () {6 FMT. Println ("Hello world! " )7 }
1) Run Hello.go directly with the Go Run command
2) Use the Go Build command to generate a hello executable file
#go build hello.go#. /hello