Go 是一种编程语言,由 Google 工程师 Robert Griesemer、Rob Pike 和 Ken Thompson 设计。

下载和解压 Golang

先去获取 Golang 的下载链接

https://go.dev/dl/
因为我是 64 位的系统,所以选 linux amd64,目前(2022.03.12)最新版链接如下
https://go.dev/dl/go1.17.8.linux-amd64.tar.gz

安装 aria2c

# apt install aria2c

下载 Golang

# aria2c -x 8 https://go.dev/dl/go1.17.8.linux-amd64.tar.gz
03/12 09:22:43 [NOTICE] Downloading 1 item(s)

03/12 09:22:44 [NOTICE] CUID#7 - Redirecting to https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz
[#a2119f 0B/0B CN:1 DL:0B]
03/12 09:22:45 [NOTICE] CUID#9 - Redirecting to https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz
[#a2119f 13MiB/128MiB(10%) CN:4 DL:17MiB ETA:6s]
03/12 09:22:46 [NOTICE] CUID#10 - Redirecting to https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz

03/12 09:22:46 [NOTICE] CUID#11 - Redirecting to https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz

03/12 09:22:46 [NOTICE] CUID#11 - Redirecting to https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz
[#a2119f 112MiB/128MiB(87%) CN:3 DL:40MiB]
03/12 09:22:48 [NOTICE] Download complete: /root/go1.17.8.linux-amd64.tar.gz

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
a2119f|OK  |    39MiB/s|/root/go1.17.8.linux-amd64.tar.gz

Status Legend:
(OK):download completed.

解压安装包

# tar -zxvf go1.17.8.linux-amd64.tar.gz -C /usr/local/

配置环境变量

现在要配置环境变量让PATH包含 Golang 的路径(/usr/local/go/bin)。
如果你想给所有用户配置,使用这个

# echo "export PATH=/usr/local/go/bin:\${PATH}" | sudo tee /etc/profile.d/go.sh

# source /etc/profile.d/go.sh

如果仅仅想给当前用户配置,选这个

# echo "export PATH=/usr/local/go/bin:\${PATH}" | sudo tee -a $HOME/.profile

# source $HOME/.profile

验证 Go 安装

运行 Go 版本获取

# go version
go version go1.17.8 linux/amd64