# Ubuntu22.04上安装和使用Go
# 1.下载和解压
wget https://studygolang.com/dl/golang/go1.22.0.linux-amd64.tar.gz
tar xfz go1.22.0.linux-amd64.tar.gz -C /usr/local
1
2
3
2
3
# 2.配置环境变量
vim /etc/profile
1
添加如下:
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH
export GOPROXY=https://goproxy.cn,direct
1
2
3
4
5
6
2
3
4
5
6
# 3.验证
source /etc/profile
go version
1
2
2