Go 环境配置
Go 版本管理
Go 版本管理工具 gvm 管理多个版本的 Golang
gvm 安装
安装 bison
1
apt-get install bison
安装 gvm
1
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
添加环境变量
1
source /root/.gvm/scripts/gvm
gvm 管理多个 go 版本
1 | root@ubuntu2404:~/.gvm/scripts# gvm help |
查看已下载 go 版本
1
gvm list
查看可下载 go 版本
1
gvm listall
安装特定 go 版本
1
gvm install go1.24.2
初始化 Go 项目
新建项目文件夹
1
2mkdir survey-test
cd survey-test初始化 Go 模块
1
2go mod init github.com/GY23333/survey-test
go: creating new go.mod: module github.com/GY23333/survey-test该步会自动生成 go.mod 文件
1
2
3module github.com/GY23333/survey-test
go 1.23.3如需获取依赖
1
go get -u github.com/gorilla/mux