直接下载压缩包
下载压缩包,然后改变软连
[wjh@node1 ~]$ go version
go version go1.22.5 linux/amd64
[wjh@node1 ~]$ which go
/usr/bin/go
[wjh@node1 ~]$ ls -al /usr/bin/|grep go$
lrwxrwxrwx 1 root root 24 Jan 12 2022 go -> /usr/local/golang/bin/go
[wjh@node1 ~]$
[wjh@node1 ~]$ ls -al /usr/local/golang
total 12
drwxr-xr-x 5 root root 65 Aug 5 17:09 .
drwxr-xr-x. 27 root root 4096 Jul 14 03:07 ..
lrwxrwxrwx 1 root root 30 Aug 5 17:09 bin -> /usr/local/golang/go1.22.5/bin
drwxr-xr-x 10 wjh wjh 257 Jan 7 2022 go1.17.6
drwxr-xr-x 10 root root 4096 Aug 31 2023 go1.21.0
drwxr-xr-x 10 root root 4096 Jun 28 04:11 go1.22.5
[wjh@node1 ~]$
这样要切换golang 版本我要自己更新软连.
使用 go install 安装
[wjh@node1 ~]$ go install golang.org/dl/go1.23.0@latest
[wjh@node1 ~]$ go1.23.0 version
go1.23.0: not downloaded. Run 'go1.23.0 download' to install to /home/wjh/sdk/go1.23.0
[wjh@node1 ~]$ go1.23.0 download
Downloaded 0.0% ( 16384 / 73590011 bytes) ...
Downloaded 13.7% (10059776 / 73590011 bytes) ...
Downloaded 36.2% (26607616 / 73590011 bytes) ...
Downloaded 57.1% (42024928 / 73590011 bytes) ...
Downloaded 75.0% (55197536 / 73590011 bytes) ...
Downloaded 90.2% (66387760 / 73590011 bytes) ...
Downloaded 100.0% (73590011 / 73590011 bytes)
Unpacking /home/wjh/sdk/go1.23.0/go1.23.0.linux-amd64.tar.gz ...
Success. You may now run 'go1.23.0'
[wjh@node1 ~]$ go1.23.0 version
go version go2.23.0 linux/amd64