当前位置:网站首页>golang版本管理gvm
golang版本管理gvm
2022-07-26 20:31:00 【张三admin】
今天小土带来一篇关于Go版本管理器gvm的小短文。废话不多说,开始安装。
安装
如果你使用的mac,mac 需要先安装xcode-select,没安装过的同学可以按照如下命令进行执行安装,这里不做太多说明了。
xcode-select --install
brew update
brew install mercurial
按照github上面指示,我们这里按照命令行进行下载gvm-installer进行安装,终端执行有问题的同学也可以到gvm-installer页面进行clone安装。
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
Cloning from https://github.com/moovweb/gvm.git to /Users/admin/.gvm
Created profile for existing install of Go at "/opt/homebrew/Cellar/go/1.18.1/libexec"
Installed GVM v1.0.22
Please restart your terminal session or to get started right away run
`source /Users/admin/.gvm/scripts/gvm`
接下来为了使gvm生效,需要执行一下上面提示的source /Users/admin/.gvm/scripts/gvm命令即可,执行结束就可以在新终端使用gvm来切换控制go的版本了。
使用
安装好了,咱们就可以来简单了解一下gvm的支持的一些功能。这下可以呼唤gvm的help选项了。
$gvm help
Usage: gvm [command]
Description:
GVM is the Go Version Manager
Commands:
version - print the gvm version number # 查看gvm的版本
get - gets the latest code (for debugging) # 获取最新的代码(一般为了调试)
use - select a go version to use (--default to set permanently) # 选择使用的Go版本 (--default 可以永久设置)
diff - view changes to Go root # 查看Go root中的变更
help - display this usage text
implode - completely remove gvm # 完全删除 gvm 和所有已安装的 Go 版本和包
install - install go versions # 安装某个版本的Go
uninstall - uninstall go versions # 卸载某个版本的Go
cross - install go cross compilers # 安装跨平台Go编译器
linkthis - link this directory into GOPATH # 将项目路径链接到GOPATH中
list - list installed go versions # 罗列已经安装的Go版本列表
listall - list available versions # 罗列可用的Go版本
alias - manage go version aliases # 管理Go版本别名
pkgset - manage go packages sets # 管理Go包的设置
pkgenv - edit the environment for a package set # 编辑Go包集合的环境
gvm的简单使用
先通过gvm listall命令来看下目前的Go版本列表,如下,列表太长了,这里Go1-15的版本列表省略了,可以看出最新的是Go1.19的beta和几个rc版本了。那么咱们接下来通过下载Go1.19的rc版本来做示例。
$gvm listall
gvm gos (available)
go1
...
go1.16
go1.16beta1
go1.16rc1
go1.16.1
go1.16.2
go1.16.3
go1.16.4
go1.16.5
go1.16.6
go1.16.7
go1.16.8
go1.16.9
go1.16.10
go1.16.11
go1.16.12
go1.16.13
go1.16.14
go1.16.15
go1.17
go1.17beta1
go1.17rc1
go1.17rc2
go1.17.1
go1.17.2
go1.17.3
go1.17.4
go1.17.5
go1.17.6
go1.17.7
go1.17.8
go1.17.9
go1.17.10
go1.17.11
go1.17.12
go1.18
go1.18beta1
go1.18beta2
go1.18rc1
go1.18.1
go1.18.2
go1.18.3
go1.18.4
go1.19beta1
go1.19rc1
go1.19rc2
release.r56
release.r57
release.r58
release.r59
release.r60
release.r57.1
release.r57.2
release.r58.1
release.r58.2
release.r60.1
release.r60.2
release.r60.3
安装一个Go版本 先看下目前使用的Go版本,小土这里使用的是go1.18.1的版本。
$go version
go version go1.18.1 darwin/arm64
安装一个最新Go1.19的rc1版本。
$gvm install go1.19rc1
Installing go1.19rc1...
* Compiling...
go1.19rc1 successfully installed!
版本切换 接下来,咱们切换一下下载好的go版本,这里使用gvm use version即可切换。
$gvm use go1.19rc1
Now using version go1.19rc1
如何永久切换呢?加上--default即可永久设置,可以通过新建终端执行go version,验证查看Go版本是否完全切换。
$gvm use go1.19rc1 --default
Now using version go1.19rc1
然后我们使用go version查看当前使用的Go版本,看来是切换成功了。那么你就可以来去自如地切换Go版本了。尤其是在调试不同Go版本带来的问题代码时候特别有用。
$go version
go version go1.19rc1 darwin/arm64
升级问题排查 若在升级Go过程中,gvm文件的状态发生错乱或者其他问题,可以通过执行rm -rf ~/.gvm来删除gvm进行问题的fix。
goland中使用 还是需要将当前版本复制到一定目录,然后设置goroot
关注我 获取更多好文

边栏推荐
- Daily practice ----- there is a group of students' grades. Arrange them in descending order. To add a student's grade, insert it into the grade sequence and keep the descending order
- Go+mysql+redis+vue3 simple chat room, the sixth bullet: use vue3 and element plus to call the interface
- 如何借助自动化工具落地DevOps|含低代码与DevOps应用实践
- Niuke multi school -journey- (map building distra+ card often optimization)
- [hcie security] dual computer hot standby - primary and standby backup
- Introduction to the billing function of wechat payment
- Remember the idea of solving the problem of invalid bound statement xxxxx once
- How to implement Devops with automation tools | including low code and Devops application practice
- 基于Hough变换的直线检测(Matlab)
- 2022 open atom global open source summit agenda express | list of sub forum agenda on July 27
猜你喜欢

How to configure the legendary SF lander to automatically read the list without a network

Mobile phone \ landline call forwarding setting method

Today, the company came across an Alibaba P8, which was really seen as the ceiling of the foundation

How to use multiple languages in a project?

【HCIA安全】双向NAT

Pointpillars: fast encoders for object detection from point clouds reading notes

Practice of microservice in solving Library Download business problems

测试用例千万不能随便,记录由一个测试用例异常引起的思考

Go+mysql+redis+vue3 simple chat room, the sixth bullet: use vue3 and element plus to call the interface
![[hcie security] dual computer hot standby - primary and standby backup](/img/3b/392aabd9915a3f0997cf7a72240d63.png)
[hcie security] dual computer hot standby - primary and standby backup
随机推荐
JDBC connection
How to use multiple languages in a project?
GOM登录器配置免费版生成图文教程
TableWidget
Redis hash和string的区别
微信支付的分账功能介绍
[HCIA security] bidirectional nat
Pointpillars: fast encoders for object detection from point clouds reading notes
Cfdiv1+2-pathwalks- (tree array + linear DP)
Redis interview questions
游览器——游览器游览器缓存
Broadcast voice H5 speechsynthesisutterance
Flash source code outline
DevSecOps,让速度和安全兼顾
Introduction of JDBC
修改excel默认编码
6种方法帮你搞定SimpleDateFormat类不是线程安全的问题
ROS2获取当前系统时间的方法
MySQL -count: the difference between count (1), count (*), and count (column name)
What is the function of the serializable interface?