Go 安装教程
1. 跨平台安装指南
Section titled “1. 跨平台安装指南”1.1. Windows 环境安装
Section titled “1.1. Windows 环境安装”直接下载并运行官方提供的 MSI 安装程序即可自动完成配置:
wget https://go.dev/dl/go1.23.4.windows-amd64.msi1.2. Linux 环境安装 (以 Ubuntu/CentOS 为例)
Section titled “1.2. Linux 环境安装 (以 Ubuntu/CentOS 为例)”在 Linux 下通常推荐通过压缩包手动解压并注入环境变量:
# 1. 下载指定版本的压缩包wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
# 2. 清理旧版本并解压到 /usr/local 目录rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz
# 3. 注入系统环境变量echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
# 4. 使环境变量立即生效source /etc/profile2. 环境验证与加速配置
Section titled “2. 环境验证与加速配置”2.1. 验证安装
Section titled “2.1. 验证安装”安装完成后,检查版本以确保环境变量配置正确:
go --version# 预期输出类似:go version go1.23.4 linux/amd642.2. 国内模块代理配置 (GOPROXY)
Section titled “2.2. 国内模块代理配置 (GOPROXY)”为了解决国内拉取 Go Modules 依赖过慢的问题,强烈建议配置国内加速镜像:
# 启用模块支持并设置代理池go env -w GOPROXY=https://goproxy.cn,direct