yum install golang
方式二、使用二进制文件安装
wget https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz
tar -zxf go1.13.5.linux-amd64.tar.gz -C /usr/local
vim /etc/profile
#golang env config
export GO111MODULE=on
export GOROOT=/usr/local/go
export GOPATH=/usr/local/go/gopath
export PATH=$PATH:$GOROOT/bin
cd /usr/local/gomkdir gopath
5、使换将变量配置生效,并查看golang的版本
source /etc/profilego version
go env -w GOPROXY=https://goproxy.cn,direct
cd /usr/local/go/gopathvim hello.go
package main
import "fmt"
func main() {
fmt.Printf("Hello, world!\n")
}
go run hello.go
Hello, world!