Skip to content

Go 安装

安装

安装预编译版本

从源码编译

参考 Installing Go from source

配置

PATH 中包含 go 即可,可以通过 go env 查看 Go 的环境变量

shell
go env

GOPROXY 代理

配置国内代理 Goproxy.cn

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

GOPRIVATE 私有仓库

Go 1.13 版本后,拉取私有仓库的方式发生了变化,需要配置环境变量,否则会报错

shell
export GOPRIVATE=github.com/<username>

同时由于 go get 默认使用的是 https 协议,如果你的私有仓库是 ssh 协议,需要配置 ~/.gitconfig 文件,添加如下配置

shell
git config --global url."git@git.xxx.com".insteadOf "https://git.xxx.com/"