写在最前

1. 开始部署

# 执行命令下载
root@tanqidi:/tmp# wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz
--2026-01-19 01:03:31--  https://go.dev/dl/go1.22.1.linux-amd64.tar.gz
Connecting to 172.31.0.1:7890... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.22.1.linux-amd64.tar.gz [following]
--2026-01-19 01:03:32--  https://dl.google.com/go/go1.22.1.linux-amd64.tar.gz
Connecting to 172.31.0.1:7890... connected.
Proxy request sent, awaiting response... 200 OK
Length: 68965341 (66M) [application/x-gzip]
Saving to: ‘go1.22.1.linux-amd64.tar.gz’

go1.22.1.linux-amd64.tar.gz                                           100%[========================================================================================================================================================================>]  65.77M  4.39MB/s    in 17s     

2026-01-19 01:03:50 (3.98 MB/s) - ‘go1.22.1.linux-amd64.tar.gz’ saved [68965341/68965341]

# 解压安装包
root@tanqidi:/tmp# tar -xf go1.22.1.linux-amd64.tar.gz 
root@tanqidi:/tmp# ll
total 67384
drwxrwxrwt  8 root root     4096 Jan 19 01:03 ./
drwxr-xr-x 22 root root     4096 Jan 18 22:10 ../
drwxrwxrwt  2 root root     4096 Jan 18 21:56 .font-unix/
drwxr-xr-x 10 root root     4096 Mar  1  2024 go/
-rw-r--r--  1 root root 68965341 Mar  6  2024 go1.22.1.linux-amd64.tar.gz
drwxrwxrwt  2 root root     4096 Jan 18 21:56 .ICE-unix/
drwxrwxrwt  2 root root     4096 Jan 18 21:56 .Test-unix/
drwxrwxrwt  2 root root     4096 Jan 18 21:56 .X11-unix/
drwxrwxrwt  2 root root     4096 Jan 18 21:56 .XIM-unix/

# 将解压出来的目录移动到/usr/local/路径中
root@tanqidi:/tmp# mv go /usr/local/

# 配置环境变量
root@tanqidi:/tmp# cat >> /etc/profile << 'EOF'
# Go environment
export GOROOT=/usr/local/go
export GOPATH=/root/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
EOF

# 立即生效
root@tanqidi:/tmp# source /etc/profile

验证 Go 是否正常
root@tanqidi:/tmp# go version
go version go1.22.1 linux/amd64

# 再看下路径(防止 PATH 问题)
root@tanqidi:/tmp# which go
/usr/local/go/bin/go
root@tanqidi:/tmp# 

# 设置 Go 国内代理 & 基本参数,不然后面拉 controller-runtime 会很慢甚至失败。
root@tanqidi:/tmp# go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=on
go env -w GOPATH=/root/go

# 验证参数
root@tanqidi:/tmp# go env | grep -E 'GOPROXY|GOPATH|GOROOT'
GOPATH='/root/go'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
root@tanqidi:/tmp# 


写在最后