1,下载

https://golang.google.cn/dl/

wget https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz

2.解压安装

https://golang.google.cn/doc/install

 tar -C /usr/local -xzf go1.13.5.linux-amd64.tar.gz

3.添加环境变量

export PATH=$PATH:/usr/local/go/bin #重启系统会消失所以需添加到用户.profile中我的测试机centos7加入到文件末 /root/.bash_profile 

linux系统 go 语言安装

source   /root/.bash_profile 

4.测试

go version 显示版本信息
go version go1.13.5 linux/amd64

 创建  hello.go

  vi hello.go

package main

import "fmt"

func main() {
	fmt.Printf("hello, world\n")
}

 go build hello.go 

 linux系统 go 语言安装

 测试成功

 5.Go 模块代理设置,解决国外网站模块下载慢或不能下载问题

linux下

echo "export GOPROXY=https://goproxy.cn" >> ~/.bash_profile && source ~/.bash_profile

windows

go env -w GOPROXY=https://goproxy.cn,direct

或 打开你的 PowerShell 并执行:

C:\> $env:GOPROXY = "https://goproxy.cn"

 参考文档

https://golang.google.cn/doc/install

https://github.com/goproxy/goproxy.cn/blob/master/README.md