https://github.com/xvrzhao/gvm
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.
https://github.com/xvrzhao/gvm
go golang gopath goroot gotools goversion gvm
Last synced: 5 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/xvrzhao/gvm
- Owner: xvrzhao
- License: mit
- Created: 2020-07-22T07:02:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-24T10:09:45.000Z (almost 4 years ago)
- Last Synced: 2024-09-26T10:13:56.393Z (over 1 year ago)
- Topics: go, golang, gopath, goroot, gotools, goversion, gvm
- Language: Go
- Homepage:
- Size: 955 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GVM

[](https://github.com/xvrzhao/gvm/issues)
[](https://github.com/xvrzhao/gvm/blob/master/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.

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](https://github.com/xvrzhao/gvm/releases).
## Commands
For examples:
```bash
# 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]
```