下载链接

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

安装说明文档

https://golang.google.cn/doc/install
上面有文档,下载后执行

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

配置环境变量
.bashrc 或者 .zshrc

  1. export PATH=$PATH:/usr/local/go/bin

设置GOPATH

  1. export GOPATH=~/go //默认是这个目录,可以修改

看一下 $ go version

设置代理,加速

https://goproxy.io/zh/

  1. go env -w GO111MODULE=on
  2. go env -w GOPROXY=https://goproxy.io,direct
  3. # 设置不走 proxy 的私有仓库,多个用逗号相隔(可选)
  4. go env -w GOPRIVATE=*.corp.example.com

也可以设置.bashrc

  1. export GOPROXY=https://goproxy.io,direct