Skip to content
/ gvm Public

GVM is a Go version manager written in Go language, it provides some useful commands like `install`, `list`, `switch` and `remove` to manage local installation of multiple Go versions.

License

Notifications You must be signed in to change notification settings

xvrzhao/gvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GVM

GitHub tag (latest SemVer) GitHub issues GitHub license

GVM is a Go version manager written in Go language, it provides some useful commands like install, list, switch and remove to manage local installation of multiple Go versions.

usage

GVM is just support for Unix-like system yet, and the working mechanism is very simple. GVM will create a gvm directory in /usr/local to host multiple versions of GOROOT, and create a symbol link named go in /usr/local referring to the specific version in gvm directory. So, you just need to add /usr/local/go/bin to $PATH environment variable to run go command, and use GVM to switch the reference of the symbol link.

Multiple versions of Go installed by GVM can share the same GOPATH compatibly, and this is also advocated by GVM.

Installation

There are two ways to install GVM.

Install by Go

If you have installed Go before, just execute the following command:

$ go install github.com/xvrzhao/gvm@latest

Note:

This will install the GVM binary into your $GOBIN (same as $GOPATH/bin) directory. If you have added $GOBIN to $PATH, you can use GVM commands directly. However, some subcommands (like switch, install, etc.) need to write files in /usr/local/, so please make sure you have the appropriate permissions. You can execute the GVM commands with root privilege, like sudo gvm [command].

But sometimes it may prompt sudo: gvm: command not found, that is, the root user cannot find GVM binary in his/her $PATH directories. Because sudo does not use shell login configurations (/etc/profile, $HOME/.bashrc, etc.) to initialize the $PATH environment variable, $GOBIN is not the part of $PATH. Therefore, when the current user is not root, you can use GVM with sudo $(which gvm) [command]. Or, thoroughly, install and use GVM under root user login.

Download the binary

Another way is downloading the binary file corresponding to your operating system in the Releases Page.

Commands

For examples:

# Install and switch to go1.16.3, mainland China require `--cn`.
$ sudo gvm install 1.16.3 --switch --cn 

# List all versions managed by GVM.
$ gvm list

# Remove go1.16.3.
$ gvm remove 1.16.3

# Switch to go1.17.
$ gvm switch 1.17

For all available commands and flags, see:

$ gvm help [subcommand]

About

GVM is a Go version manager written in Go language, it provides some useful commands like `install`, `list`, `switch` and `remove` to manage local installation of multiple Go versions.

Topics

Resources

License

Stars

Watchers

Forks

Languages