【Golang】多版本管理安装

Go 管理多个版本不用使用额外的版本管理器,直接使用 go install 即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ubuntu@vm-docker:~$ go install golang.org/dl/go1.16.15@latest
go: downloading golang.org/dl v0.0.0-20220315170520-faa7218da89a
ubuntu@vm-docker:~$
ubuntu@vm-docker:~$ $(go env GOPATH)/bin/go1.16.15
go1.16.15: not downloaded. Run 'go1.16.15 download' to install to /home/ubuntu/sdk/go1.16.15
ubuntu@vm-docker:~$ $(go env GOPATH)/bin/go1.16.15 download
Downloaded 0.0% ( 16384 / 99698554 bytes) ...
Downloaded 4.2% ( 4227040 / 99698554 bytes) ...
Downloaded 15.0% (14991248 / 99698554 bytes) ...
Downloaded 25.8% (25771872 / 99698554 bytes) ...
Downloaded 36.7% (36552496 / 99698554 bytes) ...
Downloaded 47.5% (47332480 / 99698554 bytes) ...
Downloaded 57.0% (56835664 / 99698554 bytes) ...
Downloaded 67.8% (67599872 / 99698554 bytes) ...
Downloaded 78.5% (78282160 / 99698554 bytes) ...
Downloaded 89.1% (88866144 / 99698554 bytes) ...
Downloaded 99.9% (99646160 / 99698554 bytes) ...
Downloaded 100.0% (99698554 / 99698554 bytes)
Unpacking /home/ubuntu/sdk/go1.16.15/go1.16.15.linux-arm64.tar.gz ...
Success. You may now run 'go1.16.15'
ubuntu@vm-docker:~$ $(go env GOPATH)/bin/go1.16.15 version
go version go1.16.15 linux/arm64
ubuntu@vm-docker:~$
ubuntu@vm-docker:~$ $(go env GOPATH)/bin/go1.16.15 env GOROOT
/home/ubuntu/sdk/go1.16.15