zhangrui.i
zhangrui.i
发布于 2024-03-01 / 7 阅读
0
0

Go版本管理器

g 为go多版本管理器

一. Windows安装方式

a. 直接下载发行版,解压

image-dyzs.png

b. 克隆代码到本地, 自行编译后,使用g.exe

  1. 设置环境变量及使用方式
# 1. 新增环境变量
G_EXPERIMENTAL=true
# g安装目录 g.exe所在目录
G_HOME=D:\Soft\g 
# go安装包代理地址
G_MIRROR=https://golang.google.cn/dl/  

# 2. 在环境变量Path中追加
# g 全局可执行
D:\Soft\g 
 # go 全局可执行
D:\Soft\g\go  
NAME:
  g - Golang Version Manager

 USAGE:
  g  command [arguments...]

 VERSION:
  1.2.1

 AUTHOR:
  voidint <voidint@126.com>

 COMMANDS:
    ls         List installed versions
    ls-remote  List remote versions available for install
    use        Switch to specified version
    install    Download and install a version
    uninstall  Uninstall a version
    clean      Remove files from the package download directory
    help, h    Shows a list of commands or help for one command

 GLOBAL OPTIONS:
  --help, -h     show help
  --version, -v  print the version

 COPYRIGHT:
  Copyright (c) 2019-2022, voidint. All rights reserved.

2.Linux安装方式

自动化安装

  • Linux/macOS(适用于bash、zsh)
# 建议安装前清空`GOROOT`、`GOBIN`等环境变量
$ curl -sSL https://raw.githubusercontent.com/voidint/g/master/install.sh | bash
$ echo "unalias g" >> ~/.bashrc # 可选。若其他程序(如'git')使用了'g'作为别名。
$ source ~/.bashrc # 或者 source ~/.zshrc

install.sh
l
g1.4.0.linux-amd64.zip

手动安装

wget https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz


评论