Golang Version Manager

g

GitHub release (latest by date) Build Status GoDoc codecov codebeat badge Go Report Card

注意:master分支可能处于开发之中并非稳定版本,请通过tag下载稳定版本的源代码,或通过release下载已编译的二进制可执行文件。

g是一个Linux、macOS、Windows下的命令行工具,可以提供一个便捷的多版本go环境的管理和切换。

asciicast

特性

  • 支持列出可供安装的go版本号
  • 支持列出已安装的go版本号
  • 支持在本地安装多个go版本
  • 支持卸载已安装的go版本
  • 支持在已安装的go版本之间自由切换

安装

自动化安装

  • 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

手动安装

  • 下载release的二进制压缩包

  • 将压缩包解压至PATH环境变量目录下(如/usr/local/bin

  • 编辑shell环境配置文件(如~/.bashrc~/.zshrc...)

    $ 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

使用

查询当前可供安装的stable状态的go版本

$ g ls-remote stable
  1.13.15
  1.14.7

安装目标go版本1.14.7

$ g install 1.14.7
Downloading 100% |███████████████| (119/119 MB, 9.939 MB/s) [12s:0s]
Computing checksum with SHA256
Checksums matched
Now using go1.14.7

查询已安装的go版本

$ g ls
  1.7.6
  1.11.13
  1.12.17
  1.13.15
  1.14.6
* 1.14.7

查询可供安装的所有go版本

$ g ls-remote
  1
  1.2.2
  1.3
  1.3.1
  ...    // 省略若干版本
  1.14.5
  1.14.6
* 1.14.7
  1.15rc1

切换到另一个已安装的go版本

$ g use 1.14.6
go version go1.14.6 darwin/amd64

卸载一个已安装的go版本

$ g uninstall 1.14.7
Uninstalled go1.14.7

FAQ

  • 环境变量G_MIRROR有什么作用?

    由于中国大陆无法自由访问Golang官网,导致查询及下载go版本都变得困难,因此可以通过该环境变量指定一个镜像站点(如https://golang.google.cn/dl/),g将从该站点查询、下载可用的go版本。

  • 是否支持网络代理?

    支持。可在HTTP_PROXYHTTPS_PROXYhttp_proxyhttps_proxy等环境变量中设置网络代理地址。

  • 支持哪些Windows版本?

    因为g的实现上依赖于符号链接,因此操作系统必须是Windows Vista及以上版本。

  • Windows 版本安装以后不生效?

    这有可能是因为没有把下载安装的加入到 $Path 的缘故,需要手动将 $Path 纳入到用户的环境变量中。为了方便起见,可以使用项目中的 path.ps1 的 PowerShell 脚本运行然后重新启动计算机即可。

  • 支持源代码编译安装吗?

    不支持

鸣谢

感谢nvmnrvm等工具提供的宝贵思路。

Comments
  • 不支持ARM架构

    不支持ARM架构

    尝试了下在树莓派上用这个工具,遇到的一个问题,install的时候,下载的不是ARM版本的,执行go的时候报错

    pi@raspberrypi:~ $ go version
    -bash: /home/pi/.g/go/bin/go: cannot execute binary file: Exec format error
    

    我是在Windows上交叉编译了g的源码,然后上传到树莓派上

  • go: cannot find GOROOT directory: D:\Program Files\g\go

    go: cannot find GOROOT directory: D:\Program Files\g\go

    Describe the bug/缺陷描述 成功安装g和配置好环境变量后使用任何go命令都说找不到GOROOT目录

    To Reproduce/缺陷复现步骤 Steps to reproduce the behavior:

    1. 环境变量截图 1663596070872 path: 1663596251752
    2. g和go正常 image
    3. See error 但是go加上任何参数都会找不到GOROOT目录 1663596509396

    Expected behavior/期望行为 能够正常使用go

  • 无法下载golang1.15版本

    无法下载golang1.15版本

    【问题】: $ g install 1.15 [g] Installation package not found

    查看了 #41 和 #33,推荐更新voidint/g版本

    请问如何更新该软件呢?有脚本可以一键更新吗;还是需要卸载软件后重新安装新版本;(之前已经按照的golang version会收到影响吗)

    感谢您提供的软件

  • [g] Installation package(/dl/go1.14.4.darwin-amd64.tar.gz) download failed ==> Get

    [g] Installation package(/dl/go1.14.4.darwin-amd64.tar.gz) download failed ==> Get "/dl/go1.14.4.darwin-amd64.tar.gz": unsupported protocol scheme ""

    g version 1.1.2 build: 2020-05-05T15:23:28+08:00 branch: master commit: c243baa758cf114bfff33cf703ef424887001abf

    $ echo $G_MIRROR;
    https://golang.google.cn/dl/
     $ g install 1.14.4 
    [g] Installation package(/dl/go1.14.4.darwin-amd64.tar.gz) download failed ==> Get "/dl/go1.14.4.darwin-amd64.tar.gz": unsupported protocol scheme ""
    

    Hi
    一直 install 都报这个错误,但是可以通过 g ls-remote 看到这个版本,报错信息如上 unsupported protocol scheme

  • macbook 无法安装 go1.15

    macbook 无法安装 go1.15

    g install 1.15 报错:[g] Installation package not found g 版本:1.4.0 g version 1.4.0 build: 2022-06-08T21:28:54+08:00 branch: master commit: e1fdf711f3175765997863f71ab5632ea5cf4261

  • G_MIRROR的问题

    G_MIRROR的问题

    设置了G_MIRROR https://golang.google.cn/dl/ 后,是可以正常查询,但是下载还是从官方地址下载,造成无法正常install。 出错信息: [g] Installation package(https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz) download failed ==> local error: tls: bad record MAC

  • [g] Installation package not found

    [g] Installation package not found

    Describe the bug/缺陷描述 A clear and concise description of what the bug is.

    使用mac m1安装1.14 1.15 报错 [g] Installation package not found

    安装1.16正常

    To Reproduce/缺陷复现步骤 Steps to reproduce the behavior:

    1. Go to '...'
    2. Click on '....'
    3. Scroll down to '....'
    4. See error

    Expected behavior/期望行为 A clear and concise description of what you expected to happen.

    Screenshots/实际运行结果截图 If applicable, add screenshots to help explain your problem. shell $ g install 1.14 [g] Installation package not found Environments (please complete the following information)/运行环境:

    • OS[e.g. uname -a]

    • g --version

    g --version g version 1.4.0 build: 2022-06-08T21:28:54+08:00 branch: master commit: e1fdf711f3175765997863f71ab5632ea5cf4261 ```

    • go env

      
      
    # ===== set g environment variables =====
    export GOROOT="${HOME}/.g/go"
    export PATH="${HOME}/bin:${HOME}/.g/go/bin:$PATH"
    export G_MIRROR=https://mirrors.aliyun.com/golang/
    

    Additional context/额外信息 Add any other context about the problem here.

  •  Access is denied.

    Access is denied.

    1. 安装go的时候出现重命名的Access is denied 错误。
    2. 错误信息如下: [g] Rename C:\Users\username\.g\versions\go C:\Users\username\.g\versions\1.12: Access is denied. 请问是什么原因造成的,试过用管理员方式打开powershell @voidint
Go tool for major version upgrades

GOMAJOR $ gomajor help GoMajor is a tool for major version upgrades Usage: gomajor <command> [arguments] The commands are: get upgrad

Dec 29, 2022
A simple dependency manager for Go (golang), inspired by Bundler.
A simple dependency manager for Go (golang), inspired by Bundler.

Goop A dependency manager for Go (golang), inspired by Bundler. It is different from other dependency managers in that it does not force you to mess w

Sep 27, 2022
Go Manager - bundle for go

gom - Go Manager Why The go get command is useful. But we want to fix the problem where package versions are different from the latest update. Are you

Nov 20, 2022
Barebones dependency manager for Go.
Barebones dependency manager for Go.

Go Package Manager Go Package Manager (or gpm, for short) is a tool that helps achieve reproducible builds for Go applications by specifying the revis

Dec 14, 2022
Barebones dependency manager for Go.
Barebones dependency manager for Go.

Johnny Deps Johnny Deps is a small tool from VividCortex that provides minimalistic dependency versioning for Go repositories using Git. Its primary p

Sep 27, 2022
🦄 Easy, fast and open-source local package manager for Python!

Unikorn ?? Easy, fast and open-source local package manager for Python! Key Features Speed: You can add a package in one second.

Dec 11, 2021
gPac - a linux package manager

gPac is a useless package manager. It is included in the gSuite, which is a suite of tools written in GO. gPac is a KISS - like package manager.

Mar 13, 2022
GoFish is a cross-platform systems package manager, bringing the ease of use of Homebrew to Linux and Windows.

GoFish is a cross-platform systems package manager, bringing the ease of use of Homebrew to Linux and Windows.

Dec 11, 2022
Package manager for future projects

PCKGER is a package manager for my next project but when it will be able to build binaries and move libs it will be used like a normal package manager

Dec 20, 2021
gobin is a package manager for /go/bin

gobin gobin is a package manager for /go/bin Features List installed packages. Check for updates. Install packages (like go install). Uninstall packag

Nov 12, 2022
📦 An independent package manager for compiled binaries.
📦 An independent package manager for compiled binaries.

stew An independent package manager for compiled binaries. Features Easily distribute binaries across teams and private repositories. Get the latest r

Dec 13, 2022
Package Management for Golang
Package Management for Golang

Glide: Vendor Package Management for Golang Are you used to tools such as Cargo, npm, Composer, Nuget, Pip, Maven, Bundler, or other modern package ma

Dec 27, 2022
Fetch license information for all direct and indirect dependencies of your Golang project
Fetch license information for all direct and indirect dependencies of your Golang project

gocomply beta Give open source Golang developers the credit they deserve, follow your legal obligations, and save time with gocomply. This tiny little

Nov 1, 2022
A tool to determine the highest version number that's smaller than a target version number

semver-highest A tool to determine the highest version number that's smaller than a target version number. Installation go install github.com/marten-s

Oct 13, 2021
Golang Version Manager

g 注意:master分支可能处于开发之中并非稳定版本,请通过tag下载稳定版本的源代码,或通过release下载已编译的二进制可执行文件。 g是一个Linux、macOS、Windows下的命令行工具,可以提供一个便捷的多版本go环境的管理和切换。 特性 支持列出可供安装的go版本号 支持列出已安

Dec 30, 2022
Go Version Manager

gvm By Josh Bussdieker (jbuss, jaja, jbussdieker) while working at Moovweb Currently lovingly maintained by Benjamin Knigge Pull requests and other an

Jan 9, 2023
Go Version Manager

gvm By Josh Bussdieker (jbuss, jaja, jbussdieker) while working at Moovweb Currently lovingly maintained by Benjamin Knigge Pull requests and other an

Jan 2, 2023
Go version manager. Super simple tool to install and manage Go versions. Install go without root. Gobrew doesn't require shell rehash.

gobrew Go version manager Install or update With curl $ curl -sLk https://git.io/gobrew | sh - or with go $ go get -u github.com/kevincobain2000/gobre

Jan 5, 2023
Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly

aqua Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly. Index Slid

Dec 29, 2022
Dontfile-simple - The simplest version of an online file manager

dontfile-simple The simplest version of an online file manager. Built With Golan

Jan 12, 2022