goversion

command module
v0.4.2-0...-59226fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2023 License: MPL-2.0 Imports: 18 Imported by: 0

README ΒΆ

goversion

checks pkg.go.dev goreportcard codecov

Easily switch between multiple Go versions

πŸ“Œ About

Go already supports installing multiple versions simultaneously as separate binaries, e.g. go (the main version) and go1.18 (an additional version). It works just fine when interacting with go <command> directly, but could be inconvenient when the command is wrapped with something like Makefile or shell scripts. The goversion tool attempts to solve this by symlinking go1.X.Y to go, so any additional Go version could be used as if it was the main one.

> go version
go version go1.19 darwin/arm64

> goversion use 1.18
1.18 is not installed. Looking for it on go.dev ...
# Downloading ...
Switched to 1.18

> go version
go version go1.18 darwin/arm64

πŸš€ Features

  • Use any additional Go version as the main one
  • List installed Go versions (and, optionally, all available versions)
  • Remove an installed Go version with a single command

✏️ Pre-requirements

$GOBIN (usually $HOME/go/bin) must be in your $PATH and it must take precedence over the location of the main Go binary (e.g. /usr/local/go/bin or /opt/homebrew/bin).

πŸ“¦ Install

Go
go install go-simpler.org/goversion@latest
Manual

Download a prebuilt binary from the Releases page.

πŸ“‹ Commands

Use

Switches the current Go version (will be installed if not already exists).

> goversion use 1.18
Switched to 1.18

As a special case, the main string can be provided to quickly switch to the main version.

> goversion use main
Switched to 1.19 (main)

The gotip version can be used just like any other.

> goversion use tip
Switched to tip

To update it, first switch to a stable Go version and then run gotip download.

List

Prints the list of installed Go versions. The current version is marked with the * symbol.

> goversion ls
  1.19       (main)
* 1.18
  1.17

The -a (-all) flag can be provided to print available versions from go.dev as well.

> goversion ls -a
  1.19.4     (not installed)
  1.19.3     (not installed)
# ...
  1.19       (main)
# ...
  1.2.2      (not installed)
  1          (not installed)

The full list is quite long, to limit it the -only=<prefix> flag can be used.

> goversion ls -a -only=1.18
  1.18.9     (not installed)
  1.18.8     (not installed)
# ...
* 1.18
# ...
  1.18beta2  (not installed)
  1.18beta1  (not installed)

If the -only=latest combination is provided, ls prints only the latest patch for each minor version.

> goversion ls -a -only=latest
  1.19.5     (not installed)
  1.18.10    (not installed)
# ...
  1.10.8     (not installed)
# ...
  1.2.2      (not installed)
  1          (not installed)
Remove

Removes the specified Go version (both the binary and the SDK).

> goversion rm 1.18
Removed 1.18

Documentation ΒΆ

Overview ΒΆ

Goversion is a convenience tool that allows using any Go version as the main one. It also provides basic versions management: installing, listing and removing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL