工具
安装
- 自动
- 手工
自动化
$ curl -sSL https://raw.githubusercontent.com/voidint/g/master/install.sh | bash$ echo "unalias g" >> ~/.bashrc$ source ~/.bashrc
手工安装
- 下载解压 https://github.com/voidint/g/releases
- 配置 path 追加PATH
d:\Program Files\g - 添加 path
G_MIRROR=[https://golang.google.cn/dl/](https://golang.google.cn/dl/)(for go download) - 添加 path 追加PATH
%USERPROFILE%\.g\go\bin(for windows)

$ cat>>~/.bashrc<<'EOF'export GOROOT="${HOME}/.g/go"export PATH="${HOME}/.g/go/bin:$PATH"export G_MIRROR=https://golang.google.cn/dl/EOF$ source ~/.bashrc # 或source ~/.zshrc
IDE 支持
goland
调整 goroot
调整 goroot
就目前(2022年02月)来看,g 是 Windows 上最好的 golang 多版本管理软件,golang 的官方方案也不错,不过运行go命令需要加版本号,容易和 shell脚本耦合。
vscode 路径问题
https://github.com/golang/vscode-go/issues/971
# 配置页面添加以下配置$ go env | grep -i goroot"go.alternateTools": {"go": "/root/.g/go/bin/go"}
