knowledge/docs/go/install.md
2024-08-29 16:28:47 +08:00

92 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 安装Go环境
> wandoubaba / 2024-08-29
截止本文发布时go的最新版本是`1.23.0`。
## linux
### 下载
```sh
wget https://go.dev/dl/go1.23.0.linux-amd64.tar.gz
```
### 删除旧版本
```sh
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz
```
### 解压安装
```sh
tar zxvf go1.23.0.linux-amd64.tar.gz -C /usr/local/
```
修改环境变量
```sh
touch /etc/profile.d/go.sh
vim /etc/profile.d/go.sh
```
文件内容如下,然后保存退出
```sh
export PATH=$PATH:/usr/local/go/bin
```
使环境变量立即生效
```sh
source /etc/profile.d/go.sh
```
### 验证安装
```sh
go version
```
结果应该是
```txt
go version go1.23.0 linux/amd64
```
## mac
### 下载
Intel平台
```sh
wget https://go.dev/dl/go1.23.0.darwin-amd64.pkg
```
Arm平台
```sh
wget https://go.dev/dl/go1.23.0.darwin-arm64.pkg
```
### 安装
直接在Finder中执行pkg文件或者在终端中用命令
```sh
sudo installer -pkg go1.23.0.darwin-amd64.pkg -target /usr/local/
```
### 验证安装
```sh
go version
```
结果应该是
```txt
go version go1.23.0 linux/amd64
```