ubuntu22.04.1LTS/debian11安装golang最新版本 其他linux系统通用

# ubuntu22.04.1LTS安装golang最新版本 其他linux系统通用

不建议 直接用自带的包管理器安装,后续维护会麻烦一点点

# 获取最新版本golang

https://golang.google.cn/dl/

截止2022.10.11 最新稳定版本是 1.9.2 截止2022.12.01 最新稳定版本是 1.9.3

1
2
3
4
5
6
7
8
cd ~
wget -c https://golang.google.cn/dl/go1.19.3.linux-amd64.tar.gz
tar -zxf go1.*.tar.gz -C /opt/
rm go1.*linux-amd64.tar.gz
cd /opt/
mkdir /opt/gopath 
# 修改环境变量
nano /etc/profile #或者 ~/.profile

在文末添加

1
2
3
4
5
6
7
export GO111MODULE=on
export GOROOT=/opt/go
export GOPATH=/opt/gopath
#export GOPROXY=https://goproxy.io,direct
#export GOPROXY=https://proxy.golang.com.cn,direct
export GOPROXY=https://goproxy.cn
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin 

更新生效 查看go情况

1
2
source /etc/profile
go env
# 其他问题

source会提示 /etc/profile (line 5): Unsupported use of '='. In fish, please use 'set PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"'. 这个是 fish的问题,用bash 就好了

# 相关内容

1、安装 vscode online codeserver

2、codeserver配置go开发环境的错误

3、code Server url参数 打开指定的工作区或者文件夹

4、 ubuntu22.04.1LTS安装golang最新版本

Licensed under CC BY-NC-SA 4.0
最后更新于 2022-08-02 23:25 UTC
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计