Skip to content

A command line tool to manage multiple active Go versions.

License

Notifications You must be signed in to change notification settings

VassilisPallas/gvs

Repository files navigation

GoReleaser Logo

Golang Version Switcher

Github Actions status Go report MIT License FOSSA status

Table of Contents

Intro

gvs allows you to quickly install and use different versions of Go via the command line. The installation is easy. Once installed, simply select the version you desire from the dropdown.

Example:

$ gvs
Use the arrow keys to navigate: ↓ ↑ → ←
? Select go version: 
  ▸ 1.21.3
    1.21.2
    1.21.1
    1.21.0
    1.20.10

✔ 1.21.3
Downloading...
Compare Checksums...
Unzipping...
Installing version...
1.21.3 version is installed!

$ go version
go version go1.21.3 darwin/arm64

About

gvs is a version manager for go, designed to be installed per-user, and invoked per-shell. gvs works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix and macOS.

Warning

Windows will be supported in a later version.

Installation

gvs is available for MacOS and Linux based operating systems.

Important

Make sure to delete any Go versions installed already before installing gvs.

MacOS

gvs is available via brew.

$ brew install VassilisPallas/tap/gvs

Linux

Installation for other linux operation systems.

$ curl -L https://raw.githubusercontent.com/VassilisPallas/gvs/HEAD/install.sh | bash

Install from source

Alternatively, you can install the binary from source.

Usage

Before start using gvs, read the below:

Important

gvs installs the go and gofmt binaries in $HOME/bin/. Make sure to append to your profile file: export PATH=$PATH:$HOME/bin, otherwise the terminal will not be able to find them.

Use the dropdown to select a version

$ gvs
Use the arrow keys to navigate: ↓ ↑ → ←
? Select go version: 
    1.21.3
  ▸ 1.21.2
    1.21.1
    1.21.0
    1.20.10

✔ 1.21.2
Downloading...
Compare Checksums...
Unzipping...
Installing version...
1.21.2 version is installed!

$ go version
go version go1.21.2 darwin/arm64
  1. Select the version you want to be installed by using the up and down arrows.
  2. Hit Enter to select the desired version.

See all versions including release candidates (rc)

To see a list with all versions, stable and unstable (release candidates) ones, just use the --show-all flag.

$ gvs --show-all
Use the arrow keys to navigate: ↓ ↑ → ←
? Select go version: 
  ▸ 1.21.3 (stable)
    1.21.2 (stable)
    1.21.1 (stable)
    1.21.0 (stable)
    1.21rc4 (unstable)
    1.21rc3 (unstable)
    1.21rc2 (unstable)

Install latest version

To install the latest stable version, use the --install-latest.

$ gvs --install-latest
Downloading...
Compare Checksums...
Unzipping...
Installing version...
1.21.3 version is installed!

Install specific version

To install a specific version without using the dropdown, use the --install-version=value flag.

$ gvs --install-version=1.21.3
Downloading...
Compare Checksums...
Unzipping...
Installing version...
1.21.3 version is installed!

If the Minor version is not specified (--install-version=1), the latest Minor version is selected from the given Major version.

If the Patch version is not specified (--install-version=1.21), the latest Patch version is selected from the given version.

You can also pass Release Candidates, like 1.21rc2.

Install from mod file

You can also install a version that is specified in a go.mod file. You can use the flag --from-mod. This will look for any go.mod file under the same path gvs was executed on the terminal.

$ gvs --from-mod
Downloading...
Compare Checksums...
Unzipping...
Installing version...
1.21.3 version is installed!

Delete unused versions

Every time you install a new version, gvs keeps the previous installed versions, so you can easily change between them. If you want to delete all the unused versions and keep only the current one, use the --delete-unused flag.

In the below example, the versions 1.20 and 1.19 are previously installed, and since they are not used (neither of them is the current version you use), they will be deleted after installing the new version 1.21.2.

$ gvs --delete-unused
Use the arrow keys to navigate: ↓ ↑ → ←
? Select go version: 
    1.21.3
  ▸ 1.21.2
    1.21.1
    1.21.0
    1.20.10

✔ 1.21.2
Downloading...
Compare Checksums...
Unzipping...
Installing version...
1.21.2 version is installed!
Deleting go1.20.
go1.20 is deleted.
Deleting go1.19.
go1.19 is deleted.
All the unused version are deleted!

Refresh version list

gvs caches the versions that are fetched from https://go.dev/dl in order to avoid overloading the server with requests.

The cache expires after a week, but if for any reason you'd like to force the fetch, you can use the --refresh-versions flag.

$ gvs --refresh-versions
Use the arrow keys to navigate: ↓ ↑ → ←
? Select go version: 
  ▸ 1.21.3 (stable)
    1.21.2 (stable)
    1.21.1 (stable)
    1.21.0 (stable)
    1.21rc4 (unstable)
    1.21rc3 (unstable)
    1.21rc2 (unstable)

Note

You can combine the flags --refresh-versions and --show-all to refresh the list and see all the versions.

Help

For more help you can use the --help flag.

Contributions

Contributions are very much welcomed! In order to contribute, the required version is 1.21.0. For more information regarding contributions, feel free to read the contributing.md file.

Getting started with the project

After cloning the repository on you local machine, you can run the below commands:

# install the dependencies
make install-deps

# run the tests
make test

# build the project
make build

There a many Makefile recipes, feel free to run make. The default make command will print a short documentation for each recipe.

Note

Recipes like format, lint, vet and test also run in Github Actions, but it should be nice to run them yourself as well before committing the changes. If you think this needs to be a git hook, I'll be more than happy to include it.

Licence

See LICENSE.md

FOSSA Status