一、简介
二、安装
-
进入 Goup Github 找到安装命令:
# goup (推荐 - 全平台),如果执行卡住了,可以更换网络环境,或者配置解释器网络 $ curl -sSf https://raw.githubusercontent.com/owenthereal/goup/master/install.sh | shWelcome to Goup! Goup and Go will be located at: /Users/dzm/.go The Goup command will be located at: /Users/dzm/.go/bin The go, gofmt and other Go commands will be located at: /Users/dzm/.go/current/bin To get started you need Goup's bin directory (/Users/dzm/.go/bin) and Go's bin directory (/Users/dzm/.go/current/bin) in your PATH environment variable. These two paths will be added to your PATH environment variable by modifying the profile files located at: /Users/dzm/.profile /Users/dzm/.zprofile /Users/dzm/.bash_profile Next time you log in this will be done automatically. To configure your current shell run source $HOME/.go/env. Would you like to proceed with the installation: y安装好后还需要执行一行命令,更新下环境变量
$ source $HOME/.go/env -
测试
goup是否安装成功,默认安装的go版本应该也会同时生效$ goup version goup version v0.7.0 $ go version go version go1.25.5 darwin/arm64
三、常用命令
-
安装 Go 版本
# 安装最新版 Go $ goup install # 安装指定版本 $ goup install 1.21.0 $ goup install 1.20.8 -
设置默认 Go 版本
# 设置默认 Go 版本 $ goup set 1.21.0 # 验证当前版本 $ go version -
查看版本列表
# 查看已安装的版本 $ goup list # 搜索可安装的 Go 版本 $ goup search # 搜索指定版本(支持模糊匹配) $ goup search 1.21 -
删除指定版本
# 删除不需要的版本 $ goup remove 1.20.8 -
升级 goup 本身
# 更新 goup 到最新版本 $ goup upgrade -
查看帮助信息
# 查看 goup 版本 $ goup version # 查看所有命令帮助 $ goup help # 查看特定命令的帮助 $ goup help install -
Shell 自动补全
# 生成 Bash 自动补全脚本 $ goup completion bash # 生成 Zsh 自动补全脚本 $ goup completion zsh # 生成 Fish 自动补全脚本 $ goup completion fish
四、常见问题
-
如何卸载 goup?
# 删除 goup 目录 $ rm -rf ~/.go # 然后手动删除 shell 配置文件中的以下行: # - ~/.profile # - ~/.zprofile # - ~/.bash_profile # 删除类似这样的内容: # export PATH="$HOME/.go/bin:$PATH" # export PATH="$HOME/.go/current/bin:$PATH" -
版本切换后没有生效?
# 重新加载环境变量 $ source $HOME/.go/env # 或者重启终端