Skip to content

Commit

Permalink
fix: rename to govm
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed Nov 21, 2023
1 parent 3485fd6 commit b69ab82
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 99 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,50 @@ jobs:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: goup-x86_64-unknown-linux-gnu.tar.gz
name: govm-x86_64-unknown-linux-gnu.tar.gz

- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: goup-x86_64-unknown-linux-musl.tar.gz
name: govm-x86_64-unknown-linux-musl.tar.gz

- target: i686-unknown-linux-musl
os: ubuntu-latest
name: goup-i686-unknown-linux-musl.tar.gz
name: govm-i686-unknown-linux-musl.tar.gz

- target: aarch64-unknown-linux-musl
os: ubuntu-latest
name: goup-aarch64-unknown-linux-musl.tar.gz
name: govm-aarch64-unknown-linux-musl.tar.gz

- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
name: goup-arm-unknown-linux-musleabihf.tar.gz
name: govm-arm-unknown-linux-musleabihf.tar.gz

- target: x86_64-apple-darwin
os: macOS-11
name: goup-x86_64-apple-darwin.tar.gz
name: govm-x86_64-apple-darwin.tar.gz

- target: aarch64-apple-darwin
os: macOS-11
name: goup-aarch64-apple-darwin.tar.gz
name: govm-aarch64-apple-darwin.tar.gz

- target: x86_64-pc-windows-msvc
os: windows-latest
name: goup-x86_64-pc-windows-msvc.zip
name: govm-x86_64-pc-windows-msvc.zip
rustflags: -C target-feature=+crt-static

- target: i686-pc-windows-msvc
os: windows-latest
name: goup-i686-pc-windows-msvc.zip
name: govm-i686-pc-windows-msvc.zip
rustflags: -C target-feature=+crt-static
# TODO: bug ring not supported
# - target: aarch64-pc-windows-msvc
# os: windows-latest
# name: goup-aarch64-pc-windows-msvc.zip
# name: govm-aarch64-pc-windows-msvc.zip
# rustflags: -C target-feature=+crt-static

- target: x86_64-unknown-freebsd
os: ubuntu-latest
name: goup-x86_64-unknown-freebsd.tar.gz
name: govm-x86_64-unknown-freebsd.tar.gz

runs-on: ${{ matrix.os }}
continue-on-error: true
Expand Down Expand Up @@ -108,20 +108,20 @@ jobs:
run: >
cargo wix -v --no-build --nocapture -I install/windows/main.wxs
--target ${{ matrix.target }}
--output target/wix/goup-${{ matrix.target }}.msi
--output target/wix/govm-${{ matrix.target }}.msi
- name: Post Build | Prepare artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.name }} goup.exe
7z a ../../../${{ matrix.name }} govm.exe
cd -
- name: Post Build | Prepare artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../${{ matrix.name }} goup
tar czvf ../../../${{ matrix.name }} govm
cd -
- name: Release | Upload artifacts
Expand All @@ -135,8 +135,8 @@ jobs:
if: matrix.os == 'windows-latest' && matrix.target != 'aarch64-pc-windows-msvc'
uses: actions/upload-artifact@v3
with:
name: goup-${{ matrix.target }}.msi
path: target/wix/goup-${{ matrix.target }}.msi
name: govm-${{ matrix.target }}.msi
path: target/wix/govm-${{ matrix.target }}.msi

# Create GitHub release with Rust build targets and release notes
upload_artifacts:
Expand All @@ -148,9 +148,9 @@ jobs:
uses: actions/download-artifact@v3

- name: Setup | Checksums
run: for file in goup-*/goup-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
run: for file in govm-*/govm-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done

- name: Build | Add Artifacts to Release
uses: softprops/action-gh-release@v1
with:
files: goup-*/goup-*
files: govm-*/govm-*
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
[package]
name = "goup_rs"
name = "govm"
version = "0.1.0"
authors = ["thinkgo <[email protected]>"]
edition = "2021"
rust-version = "1.70.0"
description = "goup_rs is is an elegant Go version manager"
description = "govm is is an elegant Go version manager"
keywords = [
"goup",
"gvm",
"govm",
"golang",
"installer",
"version-manager",
"tool",
]
license = "Apache-2.0"
readme = "README.md"
homepage = "https://github.com/thinkgos/goup_rs"
repository = "https://github.com/thinkgos/goup_rs"
homepage = "https://github.com/thinkgos/govm"
repository = "https://github.com/thinkgos/govm"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
Expand Down
91 changes: 26 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# goup-rs
# govm

`goup-rs` (pronounced Go Up) is an elegant Go version manager.This is [goup](https://github.com/owenthereal/goup)'s a `rust` implementation.

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](https://fedoraproject.org/wiki/DNF) is 1.14.9, while the latest Go version is 1.15.2.
`govm` is an elegant Go version manager.This is [goup](https://github.com/owenthereal/goup)'s a `rust` implementation.

There are a bunch of solutions to install Go or manage Go versions outside of a package manager:
[golang/dl](https://github.com/golang/dl), [getgo](https://github.com/golang/tools/tree/master/cmd/getgo), [gvm](https://github.com/moovweb/gvm), [goenv](https://github.com/syndbg/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 (`golang/dl` requires a Go compiler to pre-exist; `getgo` can only install the latest Go)

I want a Go version manager that:

Expand All @@ -18,88 +14,53 @@ I want a Go version manager that:
* 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](https://rustup.rs/), [golang/dl](https://github.com/golang/dl) and [getgo](https://github.com/golang/tools/tree/master/cmd/getgo).
`govm` is an attempt to fulfill the above features and is heavily inspired by [Rustup](https://rustup.rs/), [golang/dl](https://github.com/golang/dl) and [getgo](https://github.com/golang/tools/tree/master/cmd/getgo).

## Installation

### One-liner

```shell
cargo install --git github.com/thinkgos/goup_rs
cargo install govm --git https://github.com/thinkgos/govm
```

### Manual

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

* Download the latest `goup` from `https://github.com/thinkgos/goup_rs/releases`
* Drop the `goup` executable to your `PATH` and make it executable: `mv GOUP_BIN /usr/local/bin/goup && chmod +x /usr/local/bin/goup`
* Download the latest `govm` from `https://github.com/thinkgos/govm/releases`
* Drop the `govm` executable to your `PATH` and make it executable: `mv GOVM_BIN /usr/local/bin/govm && chmod +x /usr/local/bin/govm`
* Add the Go bin directory to your shell startup script: `echo 'export PATH="$HOME/.go/current/bin:$PATH"' >> ~/.bashrc`

## Quick Start

```shell
$ 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'
$ goup ls
go1.15.2
$ go env GOROOT
/home/owen/.go/go1.15.2
$ go version
go version go1.15.2 linux/amd64

$ 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'
$ goup ls
gotip
$ govm install
Installing go1.21.4 ...
Unpacking /home/thinkgo/.go/go1.21.4/go1.21.4.linux-amd64.tar.gz ...
Success: go1.21.1 installed in /home/thinkgo/.go/go1.21.4
Default Go is set to 'go1.21.4'
$ govm list
| VERSION | ACTIVE |
|---------|--------|
| 1.21.4 | * |
$ go env GOROOT
/home/owen/.go/gotip
/home/thinkgo/.go/current
$ go version
go version devel +5d13781 Thu Oct 8 00:28:09 2020 +0000 linux/amd64


$ GOUP_GO_HOST=golang.google.cn goup install
go version go1.21.4 linux/amd64
$ GOVM_GO_HOST=golang.google.cn govm install
```

## How it works

* `install.sh` downloads the latest Goup release for your platform and appends Goup's bin directory (`$HOME/.go/bin`) & Go's bin directory (`$HOME/.go/current/bin`) to your PATH environment variable.
* `goup_rs` switches to selected Go version.
* `goup_rs set` switches to selected Go version.
* `goup_rs install` downloads specified version of Go to`$HOME/.go/VERSION` and symlinks it to `$HOME/.go/current`.
* `goup_rs ls` list all installed Go version located at `$HOME/.go/current`.
* `goup_rs remove` removes the specified Go version.
* `goup_rs search` lists all available Go versions from `https://golang.org/dl`.
* `goup_rs upgrade` upgrades goup.
* `govm completion <SHELL>` Generate the autocompletion script for the specified shell.
* `govm [help]` Print this message or the help of the given subcommand(s).
* `govm install/update [VERSION]` downloads specified version of Go to`$HOME/.go/VERSION` and symlinks it to `$HOME/.go/current`.
* `govm use/set [VERSION]` switches to selected Go version.
* `govm ls/list` list all installed Go version located at `$HOME/.go/current`.
* `govm remove [VERSION]` removes the specified Go version.
* `govm search [VERSION]` lists all available Go versions from `https://golang.org/dl`.
* `govm upgrade` upgrades `govm`.

## License

Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
Some(true) => {}
// rustc version too small or can't figure it out
_ => {
eprintln!("'goup_rs' requires rustc >= {}", MIN_VERSION);
eprintln!("'govm' requires rustc >= {}", MIN_VERSION);
std::process::exit(1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct Install {
/// an optional change list (CL), If the version is 'tip'
cl: Option<String>,
/// host that is used to download Go.
#[arg(long, default_value_t = consts::GO_HOST.to_owned(), env = "GOUP_GO_HOST")]
#[arg(long, default_value_t = consts::GO_HOST.to_owned(), env = "GOVM_GO_HOST")]
host: String,
}

Expand Down
2 changes: 1 addition & 1 deletion src/command/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Run for List {
let vers = Version::list_local_version()?;
if vers.is_empty() {
println!(
"No Go is installed by goup.{}",
"No Go is installed by govm.{}",
if let Ok(go_bin) = which("go") {
format!(" Using system Go {}.", go_bin.to_string_lossy())
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub enum Command {
/// If no version is provided, a prompt will show to select a installed Go version.
#[command(visible_alias = "use")]
Set(Set),
/// Upgrade goup
/// Upgrade govm
Upgrade(Upgrade),
/// Generate the autocompletion script for the specified shell
Completion(Completion),
Expand Down
8 changes: 4 additions & 4 deletions src/consts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ pub const GO_SOURCE_GIT_URL: &str = "https://github.com/golang/go";
pub const GO_SOURCE_UPSTREAM_GIT_URL: &str = "https://go.googlesource.com/go";

pub fn go_host() -> String {
get_var_or_else("GOUP_GO_HOST", || GO_HOST.to_owned())
get_var_or_else("GOVM_GO_HOST", || GO_HOST.to_owned())
}

pub fn go_download_base_url() -> String {
get_var_or_else("GOUP_GO_DOWNLOAD_BASE_URL", || {
get_var_or_else("GOVM_GO_DOWNLOAD_BASE_URL", || {
GO_DOWNLOAD_BASE_URL.to_owned()
})
}

pub fn go_source_git_url() -> String {
get_var_or_else("GOUP_GO_SOURCE_GIT_URL", || GO_SOURCE_GIT_URL.to_owned())
get_var_or_else("GOVM_GO_SOURCE_GIT_URL", || GO_SOURCE_GIT_URL.to_owned())
}

pub fn go_source_upstream_git_url() -> String {
get_var_or_else("GOUP_GO_SOURCE_GIT_URL", || {
get_var_or_else("GOVM_GO_SOURCE_GIT_URL", || {
GO_SOURCE_UPSTREAM_GIT_URL.to_owned()
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::Parser;

use goup_rs::command::Cli;
use goup_rs::command::Run;
use govm::command::Cli;
use govm::command::Run;

fn main() -> Result<(), anyhow::Error> {
Cli::parse().run()
Expand Down
2 changes: 1 addition & 1 deletion src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Version {
let home: std::path::PathBuf = Dir::home_dir()?;
if !Dir::is_dot_unpacked_success_exists(&home, &version) {
return Err(anyhow!(
"Go version {version} is not installed. Install it with `goup install`."
"Go version {version} is not installed. Install it with `govm install`."
));
}
let version_dir = Dir::new(&home).version(&version);
Expand Down

0 comments on commit b69ab82

Please sign in to comment.