Goup - Elegant Go Version Manager

2 minute read

Goup (pronounced Go Up) is an elegant solution to install Go and manage Go versions.

It is notorious that an operating system’s package manager takes time to update Go to the latest version, particularly on Linux distros. At the time of this writing in October 2020, Fedora 32’s Go version from dnf is 1.14.9, while the latest Go version is 1.15.2.

There are a bunch of solutions to install Go or manage Go versions outside of a package manager: dl, getgo, gvm, goenv, to name a few. All of them either do not work well on all Linux distros (I ran into errors with gvm and goenv on Fedora) or do not provide the developer experience that I like (dl requires a Go compiler to pre-exist; getgo can only install the latest Go)

I want a Go version manager that:

  • Has a minimum prerequisite to install, e.g., does not need a Go compiler to pre-exist.
  • Is installed with a one-liner.
  • Runs well on all operating systems (at least runs well on *uix as a start).
  • Installs any version of Go (any version from golang.org/dl or tip) and switches to it.
  • Does not inject magic into your shell.
  • Is written in Go.

goup is an attempt to fulfill the above features and is heavily inspired by Rustup, golang/dl and getgo

You can install goup with one line:

curl -sSf https://raw.githubusercontent.com/owenthereal/goup/master/install.sh | sh

You can install the latest Go and switch to it:

$ goup install
Downloaded   0.0% (    32768 / 121149509 bytes) ...
Downloaded  12.4% ( 15007632 / 121149509 bytes) ...
Downloaded  30.2% ( 36634352 / 121149509 bytes) ...
Downloaded  47.6% ( 57703440 / 121149509 bytes) ...
Downloaded  65.9% ( 79855008 / 121149509 bytes) ...
Downloaded  84.2% (101972672 / 121149509 bytes) ...
Downloaded 100.0% (121149509 / 121149509 bytes)
INFO[0030] Unpacking /home/owen/.go/go1.15.2/go1.15.2.linux-amd64.tar.gz ...
INFO[0043] Success: go1.15.2 downloaded in /home/owen/.go/go1.15.2
INFO[0043] Default Go is set to 'go1.15.2'

You can check the currently active Go version:

$ goup show

You can install tip and switch to it. Go tip means the tip of the Go development tree. The following compiles Go from the latest source:

$ goup install tip
Cloning into '/home/owen/.go/gotip'...
remote: Counting objects: 10041, done
remote: Finding sources: 100% (10041/10041)
remote: Total 10041 (delta 1347), reused 6538 (delta 1347)
Receiving objects: 100% (10041/10041), 23.83 MiB | 3.16 MiB/s, done.
Resolving deltas: 100% (1347/1347), done.
Updating files: 100% (9212/9212), done.
INFO[0078] Updating the go development tree...
From https://go.googlesource.com/go
 * branch            master     -> FETCH_HEAD
HEAD is now at 5d13781 cmd/cgo: add more architectures to size maps
Building Go cmd/dist using /home/owen/.go/go1.15.2. (go1.15.2 linux/amd64)
Building Go toolchain1 using /home/owen/.go/go1.15.2.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.
Installed Go for linux/amd64 in /home/owen/.go/gotip
Installed commands in /home/owen/.go/gotip/bin
INFO[0297] Default Go is set to 'gotip'

If you want to learn more, the soruce is here.

Happy Go Uping!

Categories: ,