To install the GO Runtime environment, if you upgrade from the previous version of Go, you must first delete the existing version.
1. Binary Package Installation
Download package
Cd/usr/local/src
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
Binary package installation is very simple, directly decompression can be
Tar zxvf go1.8.3.linux-amd64.tar.gz-c/usr/local
Add/usr/local/go/bin to PATH environment variable
Export path= $PATH:/usr/local/go/bin
Installation Complete View version number
[[email protected] local]# go version
Go version go1.8.3 linux/amd64
Install to a custom location
Go assumes that they are installed in/usr/local/go (or c:\GoWindows) and can also be customized for installation to other locations. In this case, you must set the GOROOT environment variable to point to the installation directory.
For example, if you install go to your home directory, you should add the following command to $home/.profile:
Export goroot= $HOME/go1. X
Export path= $PATH: $GOROOT/bin
Note: Goroot must be set only if you are installing to a custom location.
2. Compiling the installation
1) Install Go1.4 first
Go 1.4 is the last version written in C, because later versions are written in the go language, and we need to use Go1.4 as a compiler to compile them.
Download the Go1.4 source package, which contains the Go 1.4 source code as well as the cumulative patches.
Cd/usr/local/src
wget https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.tar.gz
Unpack the Package
Tar zxvf go1.4-bootstrap-20170531.tar.gz
MV go/usr/local/go1.4
Compile
Cd/usr/local/go1.4/src
./make.bash
2) Install Go1.8.3
Download Go1.8.3
Cd/usr/local/src
wget https://storage.googleapis.com/golang/go1.8.3.src.tar.gz
Extract
Tar zxvf go1.8.3.src.tar.gz-c/usr/local
cd/usr/local/go/src/
The compilation script looks for the compiler's location from the $goroot_bootstrap variable. If not set, the default value of Goroot_bootstrap is $home/go1.4.
Setting the installation directory for go1.4
Export goroot_bootstrap=/usr/local/go1.4
Compiling go1.8.3
./make.bash
Add/usr/local/go/bin to PATH environment variable
Export path= $PATH:/usr/local/go/bin
If your customizations are installed to a different location, set the GOROOT environment variable to point to the installation directory, for example:
Export goroot= $HOME/go1. X
View version number after installation
[[email protected] local]# go version
Go version go1.8.3 linux/amd64
3. Test:
Vi/tmp/hello.go
Add the following content:
Package Mainimport "FMT" Func Main () {FMT. Printf ("Hello, woymk!\n")}
Save after execution
[email protected] ~]# go run/tmp/hello.go
Hello, woymk!.
[Email protected] ~]#
The above output indicates that the go Language run environment is installed successfully!
This article is from the "WOYMK" blog, make sure to keep this source http://woymk.blog.51cto.com/10000269/1954335
Install the Go Language runtime environment