多版本Golang管理工具

声明

本文版权归原作者所有,未经允许禁止转载。

自动安装

不推荐。

手动安装

新建文件夹

mkdir ~/.g/bin

解压

下载:

https://gh-proxy.com/https://github.com/voidint/g/releases/download/v1.8.0/g1.8.0.windows-amd64.zip

解压至 ~/.g/bin

设置环境变量

Windows

setx GOROOT "%USERPROFILE%\.g\go"
setx GOPATH "%USERPROFILE%\.g\go\gopath"
setx GOPROXY "https://mirrors.aliyun.com/goproxy/,direct"
[Environment]::SetEnvironmentVariable("PATH", [Environment]::GetEnvironmentVariable("PATH", "User") + ";%USERPROFILE%\.g\bin" + ";%USERPROFILE%\.g\go\bin" + ";%USERPROFILE%\.g\go\gopath\bin","User")

安装 go

g install 1.20.13

列出可安装的 go 版本

g ls-remote

列出已安装的 go 版本

g ls

切换 go 版本

g use 1.20.13