下载源码
go1.10.3.linux-amd64.tar.gz
https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
解压
# cd /usr/local/
# tar -zxvf go1.10.3.linux-amd64.tar.gz
添加环境变量
# vim /etc/profile
// 在最后一行添加
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
// wq保存退出后source一下
# source /etc/profile
验证
# go version
go version go1.10.3 linux/amd64
Hello World!
HelloWorld.go
package main
import "fmt"
func main(){
fmt.Println("Hello World!")
}
# go run HelloWorld.go
Hello World!