voidint / g

Golang Version Manager
https://pkg.go.dev/github.com/voidint/g
MIT License
1.72k stars 199 forks source link
golang version-manager

g

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

简体中文 🇨🇳

Note: The master branch may still be under development and may not represent a stable version. Please download stable versions of the source code through tags or download compiled binary executables through release.

g is a command-line tool for Linux, macOS, and Windows that provides convenient management and switching of multiple versions of the Go environment.

asciicast

Features

Installation

Automated Installation

Manual Installation(for Linux/macOS)

Manual Installation (for Windows PowerShell)

Usage

To query the currently available stable versions of Go for installation:

$ g ls-remote stable
  1.19.10
  1.20.5

To install a specific version of Go (e.g., 1.20.5):

$ g install 1.14.7
Downloading 100% [===============] (92/92 MB, 12 MB/s)               
Computing checksum with SHA256
Checksums matched
Now using go1.20.5

To query the list of installed Go versions:

$ g ls
  1.19.10
* 1.20.5

To list all available Go versions for installation:

$ g ls-remote
  1
  1.2.2
  1.3
  1.3.1
  ...    
  1.19.10
  1.20rc1
  1.20rc2
  1.20rc3
  1.20
  1.20.1
  1.20.2
  1.20.3
  1.20.4
* 1.20.5

To switch to another installed Go version:

$ g use 1.19.10
go version go1.19.10 darwin/arm64

To uninstall a specific installed Go version:

$ g uninstall 1.19.10
Uninstalled go1.19.10

To clear the package file cache for Go installations:

$ g clean 
Remove go1.18.10.darwin-arm64.tar.gz
Remove go1.19.10.darwin-arm64.tar.gz
Remove go1.20.5.darwin-arm64.tar.gz

To view the version information of g itself:

g version 1.5.0
build: 2023-01-01T21:01:52+08:00
branch: master
commit: cec84a3f4f927adb05018731a6f60063fd2fa216

To update g software itself:

$ g self update
You are up to date! g v1.5.0 is the latest version.

To uninstall the g software itself:

$ g self uninstall
Are you sure you want to uninstall g? (Y/n)
y
Remove /Users/voidint/.g/bin/g
Remove /Users/voidint/.g

FAQ

Acknowledgement

Thanks to tools like nvm, n, rvm for providing valuable ideas.