在 Ubuntu 手动安装 Go
date
Jan 12, 2023
slug
ubuntu-install-go-manually
status
Published
tags
Go
Linux
ENV
summary
非常想念 Arch Linux 的 pacman。
type
Post
一、安装
1. 从官网下载二进制文件
下载并且解压 Go 二进制文件到
/usr/local 目录,这步一定需要 root 账户!wget -c https://dl.google.com/go/go1.19.4.linux-amd64.tar.gz -O - | tar -xz -C /usr/local2. 设置全局环境变量(系统范围内安装)
添加下面的行到
/etc/profile 文件,然后执行 source ~/.profile 使新修改的环境变量生效。export PATH=$PATH:/usr/local/go/bin如果使用的是其他 shell,请在对应 shell 的配置文件中使/etc/profile配置文件生效。例如我使用的是 zsh,我就需要在~/.zshrc内添加一行/etc/profile。
3. 验证是否安装成功
向 shell 输入
go version 即可看到当前的 go 版本。二、更新
重新执行第一个安装步骤的命令:
wget -c https://dl.google.com/go/go1.19.4.linux-amd64.tar.gz -O - | tar -xz -C /usr/local三、国内代理
直接在 shell 运行:
go env -w GOPROXY=https://goproxy.cn,https://gocenter.io,https://goproxy.io,direct