#goup #golang #version-manager #tool #rust

goup-version

goup is an elegant Go version manager

11 releases (4 breaking)

new 0.6.2 Feb 17, 2024
0.6.1 Feb 7, 2024
0.5.0 Jan 30, 2024
0.4.0 Jan 19, 2024
0.2.5 Nov 30, 2023

#291 in Development tools

Download history 67/week @ 2023-11-28 12/week @ 2023-12-05 87/week @ 2023-12-12 9/week @ 2023-12-19 57/week @ 2023-12-26 15/week @ 2024-01-02 11/week @ 2024-01-09 97/week @ 2024-01-16 10/week @ 2024-01-23 111/week @ 2024-01-30 43/week @ 2024-02-06 241/week @ 2024-02-13

409 downloads per month
Used in 2 crates

Apache-2.0

30KB
541 lines

goup

goup is an elegant Go version manager write in rust.

Rust Crates.io MSRV Crates.io Total Downloads Crates.io Crates Licence Tag

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

NOTE: Please keep in mind that goup-rs is still under active development and therefore full backward compatibility is not guaranteed before reaching v1.0.0.

Features

  • Minimum dependencies, only depend on git. we may remove this dependency in future.
  • Multi-platform compatible (Linux, macOS & Windows).
  • Install/Remove Go versions with goup install/remove. Such as tip version.
  • List locally installed versions.
  • Switch between multiple versions.
  • Search available version of Go.
  • Upgrade goup itself.
  • Friendly prompt.
  • Should be pretty fast.

Installation

Cargo

Alternatively, you can also install it using cargo.

cargo install goup-rs

or

cargo install goup-rs --git https://github.com/thinkgos/goup-rs

Manual(for Linux/MacOS)

If you want to install manually, there are the steps:

  • Download the latest goup from Release Page
  • Drop the goup executable to your PATH and make it executable: mv GOUP_BIN /usr/local/bin/goup && chmod +x /usr/local/bin/goup
  • Run goup init, Got shell startup script at $HOME/.goup/env.
  • Add the Go bin directory to your shell startup script: echo '. "$HOME/.goup/env"' >> ~/.bashrc or echo '. "$HOME/.goup/env"' >> ~/.zshenv

Manual(for Windows)

MSI-installers

Install the latest version for your system with the MSI-installers from the Release Page section

Binary Compressed

  • Download the binary compressed file for Windows version from Release Page, and then unzipping it.
  • Move the goup.exe to $YOUR_PATH.
  • Add the $YOUR_PATH to windows environment.

Quick Start

$ goup install
[2024-01-30T00:38:48Z INFO ] Installing go1.21.6 ...
[2024-01-30T00:38:48Z INFO ] Unpacking /home/thinkgo/.goup/go1.21.6/go1.21.6.linux-amd64.tar.gz ...
[2024-01-30T00:38:48Z INFO ] go1.21.6 installed in /home/thinkgo/.goup/go1.21.6
[2024-01-30T00:38:48Z INFO ] Default Go is set to 'go1.21.6'
$ goup list
| VERSION | ACTIVE |
|---------|--------|
| 1.21.6  |   *    |
$ go env GOROOT
/home/thinkgo/.goup/current
$ go version
go version go1.21.6 linux/amd64
$ GOUP_GO_HOST=https://golang.google.cn goup install 1.21.6

Usage

Lists all available Go versions from https://golang.org/dl

goup search [FILTER], [FILTER] can be follow value 'stable', "unstable", 'beta' or any regex string.

$ goup search
1
...
1.21rc4
1.22rc1
$ goup search stable
1
...
1.21.4
1.21.5
1.21.6

List all installed Go version located at $HOME/.goup

$ goup list 
+---------+--------+
| Version | Active |
+---------+--------+
| 1.21.5  |        |
+---------+--------+
| 1.21.6  |   *    |
+---------+--------+
| tip     |        |
+---------+--------+

Install specified version of Go

goup install/update [TOOLCHAIN], [TOOLCHAIN] can be follow value 'stable'(default), 'nightly'('tip', 'gotip'), 'unstable', 'beta' or '1.21.4'('go1.21.4'), --dry flag means only install the version, but do not switch

$ goup install
[2024-01-30T00:38:48Z INFO ] Installing go1.21.6 ...
[2024-01-30T00:38:48Z INFO ] Unpacking /home/thinkgo/.goup/go1.21.6/go1.21.6.linux-amd64.tar.gz ...
[2024-01-30T00:38:48Z INFO ] go1.21.6 installed in /home/thinkgo/.goup/go1.21.6
[2024-01-30T00:38:48Z INFO ] Default Go is set to 'go1.21.6'
$ goup install 1.21.4 --dry
[2024-01-30T00:38:48Z INFO ] Installing go1.21.4 ...
[2024-01-30T00:38:48Z INFO ] Unpacking /home/thinkgo/.goup/go1.21.4/go1.21.4.linux-amd64.tar.gz ...
[2024-01-30T00:38:48Z INFO ] go1.21.6 installed in /home/thinkgo/.goup/go1.21.4

Switches to selected Go version

goup use/set [VERSION], switches to selected Go version.

$ goup use 
? Select a version ›
  1.21.5
 1.21.6
  tip
[2024-01-30T00:38:48Z INFO ] Default Go is set to 'go1.21.6'

Remove the specified Go version list

goup remove/rm [VERSION]... Remove the specified Go version list. If no version is provided, a prompt will show to select multiple installed Go version

$ goup rm
? Select multiple version ›
 1.21.5
 1.21.6
 tip
 Select multiple version · 1.21.5

Manage download archive files

$ goup dl show --contain-sha256
go1.21.6.linux-amd64.tar.gz
go1.21.6.linux-amd64.tar.gz.sha256

$ goup dl clean
 Do you want to clean archive file? · yes

Modify the goup installation

$ goup self update
Checking target-arch... x86_64-unknown-linux-gnu
Checking current version... v0.3.0
Checking latest released version... v0.3.0
[2024-01-30T00:38:48Z INFO ] Update status: `v0.3.0`!

Environment

$ goup env
+---------------------------+--------------------------------+---------------------------------------------------------------------------------+
| Key                       | Value                          | Explain                                                                         |
+---------------------------+--------------------------------+---------------------------------------------------------------------------------+
| GOUP_GO_HOST              | https://go.dev                 | Get upstream latest go version, use by 'install'                                |
+---------------------------+--------------------------------+---------------------------------------------------------------------------------+
| GOUP_GO_DOWNLOAD_BASE_URL | https://dl.google.com/go       | Download go archive file base url, use by 'install'                             |
+---------------------------+--------------------------------+---------------------------------------------------------------------------------+
| GOUP_GO_SOURCE_GIT_URL    | https://github.com/golang/go   | Upstream source git url and get upstream go versions, use by 'install'/'search' |
+---------------------------+--------------------------------+---------------------------------------------------------------------------------+
| GOUP_GO_SOURCE_GIT_URL    | https://go.googlesource.com/go | Upstream source git url, use by 'install' the gotip                             |
+---------------------------+--------------------------------+---------------------------------------------------------------------------------+

More information

goup -h get more information

How it works

  • goup completion <SHELL> Generate the autocompletion script for the specified shell.
  • goup [help] Print this message or the help of the given subcommand(s).
  • goup install/update [TOOLCHAIN] downloads specified version of Go to$HOME/.goup/go<VERSION|tip>/go and symlinks it to $HOME/.goup/current.
  • goup use/set [VERSION] switches to selected Go version.
  • goup ls/list/show list all installed Go version located at $HOME/.goup.
  • goup remove/rm [VERSION]... remove the specified Go version list.
  • goup search [FILTER] lists all available Go versions.
  • goup downloads [COMMAND] Manage download archive files.
  • goup upgrade upgrades goup, deprecated in future version, use goup self update instead
  • goup self <COMMAND> Modify the goup installation.
  • goup init write all necessary environment variables and values to $HOME/.goup/env.
  • goup env Show the specified goup environment variables and values.

FAQ

  • TODO...

License

Apache 2.0

Dependencies

~6–20MB
~292K SLoC