go语言,golang,linux,unbantu安装

发布于:2024-05-21 ⋅ 阅读:(83) ⋅ 点赞:(0)

查看系统是arm还是amd
uname -m 命令可以显示系统的架构类型:

uname -m

输出可能是:

  • x86_64:表示是 AMD64 架构(即 64 位的 x86 架构)。
  • aarch64:表示是 ARM64 架构(即 64 位的 ARM架构)
  • armv7l 或 armv6l:表示是 32 位的 ARM 架构。

去https://golang.google.cn/dl/,选择和自己架构相同的版本下载,直接点击下载然后复制到服务器
或者右键选择:复制链接地址
在这里插入图片描述

在服务器执行:wget https://golang.google.cn/dl/go1.22.3.linux-amd64.tar.gz

root@main:/usr/local/soft# wget https://golang.google.cn/dl/go1.22.3.linux-amd64.tar.gz
--2024-05-15 02:19:43--  https://golang.google.cn/dl/go1.22.3.linux-amd64.tar.gz
Resolving golang.google.cn (golang.google.cn)... 114.250.67.34
Connecting to golang.google.cn (golang.google.cn)|114.250.67.34|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.22.3.linux-amd64.tar.gz [following]
--2024-05-15 02:19:43--  https://dl.google.com/go/go1.22.3.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 114.250.67.33
Connecting to dl.google.com (dl.google.com)|114.250.67.33|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 68958945 (66M) [application/x-gzip]
Saving to: ‘go1.22.3.linux-amd64.tar.gz’

go1.22.3.linux-amd64.tar.gz                                            100%[=========================================================================================================================================================================>]  65.76M  10.4MB/s    in 6.2s    

2024-05-15 02:19:49 (10.5 MB/s) - ‘go1.22.3.linux-amd64.tar.gz’ saved [68958945/68958945]

root@main:/usr/local/soft# ls
go1.22.3.linux-amd64.tar.gz
root@main:/usr/local/soft# 

然后解压缩: sudo tar -xzf go1.22.3.linux-amd64.tar.gz

root@main:/usr/local/soft# sudo tar -xzf  go1.22.3.linux-amd64.tar.gz
root@main:/usr/local/soft# ls
go  go1.22.3.linux-amd64.tar.gz
root@main:/usr/local/soft# 

接着配置环境:

vim ~/.profile

加入

export GOPATH=$HOME/go
export GOROOT=/usr/local/soft/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

返回然后

source ~/.profile

接着输入go version检查

root@main:/usr/local/soft# go version
go version go1.22.3 linux/amd64
root@main:/usr/local/soft# 

网站公告

今日签到

点亮在社区的每一天
去签到