stefanmaric / G

Licence: mit
Simple go version manager, gluten-free

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
golang
3204 projects
bash
514 projects

Projects that are alternatives of or similar to G

Gitmux
💻 Git in your tmux status bar
Stars: ✭ 180 (-41.37%)
Mutual labels:  cli, zsh, fish
Awesome Shell
A curated list of awesome command-line frameworks, toolkits, guides and gizmos. Inspired by awesome-php.
Stars: ✭ 22,631 (+7271.66%)
Mutual labels:  cli, zsh, fish
Installer
dmd installers for various systems
Stars: ✭ 74 (-75.9%)
Mutual labels:  installer, fish, version-manager
Fzf
🌸 A command-line fuzzy finder
Stars: ✭ 40,965 (+13243.65%)
Mutual labels:  cli, zsh, fish
Gh
Easily manage your local git repos
Stars: ✭ 156 (-49.19%)
Mutual labels:  cli, zsh, fish
Forgit
💤 A utility tool powered by fzf for using git interactively.
Stars: ✭ 1,823 (+493.81%)
Mutual labels:  cli, zsh, fish
Autocomplete
Autocomplete for terminals on MacOS
Stars: ✭ 569 (+85.34%)
Mutual labels:  cli, zsh, fish
Kafkactl
Command Line Tool for managing Apache Kafka
Stars: ✭ 177 (-42.35%)
Mutual labels:  cli, zsh, fish
Zoxide
A smarter cd command. Supports all major shells.
Stars: ✭ 4,422 (+1340.39%)
Mutual labels:  cli, zsh, fish
Installomator
Installation script to deploy standard software on Macs
Stars: ✭ 159 (-48.21%)
Mutual labels:  installer, zsh
Baulk
baulk - Minimal Package Manager for Windows
Stars: ✭ 177 (-42.35%)
Mutual labels:  installer, portable
kebechet
I'm Kebechet bot, goddess of freshness - I will keep your source code fresh and up-to-date
Stars: ✭ 23 (-92.51%)
Mutual labels:  dependency-manager, version-manager
Mint
A package manager that installs and runs executable Swift packages
Stars: ✭ 1,750 (+470.03%)
Mutual labels:  installer, dependency-manager
Goup
Elegant Go installer
Stars: ✭ 94 (-69.38%)
Mutual labels:  installer, version-manager
Image Bootstrap
⛅️ Creates (chroots and) bootable virtual machine images; command line tool (Python 3)
Stars: ✭ 178 (-42.02%)
Mutual labels:  installer, cli
carapace-bin
multi-shell multi-command argument completer
Stars: ✭ 42 (-86.32%)
Mutual labels:  zsh, fish
zarch
The Ultimate Script For Arch Linux
Stars: ✭ 49 (-84.04%)
Mutual labels:  zsh, installer
U3d
U3d is a cross-platform set of tools to interact with Unity3D from command line.
Stars: ✭ 309 (+0.65%)
Mutual labels:  installer, cli
config
Fig's integrations with bash, zsh, fish, ssh, and tmux. Also contains Fig's installation and update scripts. Finally, this repo is the root of the .fig folder that is installed on your computer when you download Fig!
Stars: ✭ 44 (-85.67%)
Mutual labels:  zsh, fish
hoard
cli command organizer written in rust
Stars: ✭ 71 (-76.87%)
Mutual labels:  zsh, fish

g

Simple go version manager, gluten-free.

screencast

Why?

Existing version managers build go from source, have too many dependencies, pollute the PATH, and/or require you to use a specific shell environment. g aims to be as unobtrusive and portable as possible.

g is inspired by tj/n - which I have contributed to in the past - and borrows some of its code.

Features

  • Run any go version on demand.
  • Single portable shell script that ideally lives where your go binaries live.
  • Works no matter what shell you use as long as $GOPATH and $GOROOT are exported which...
  • ...is idiomatic to go and not specific to g.
  • No need to source functions in your shell config.
  • Downloads pre-built binaries so it is fast and...
  • ...requires no git, no mercurial, no gcc, no xcode, etc.
  • curl and wget first-class support alike.
  • Colorful UI and interactive but safe to pipe and use in automated scripts.
  • self-upgrade command to keep up-to-date.
  • Option to get go beta versions.
  • Get started in golang with a single line using the install script.
  • The install script detects name collisions and helps you set an alternative name.

Requirements

Not strictly necessary, but highly recommended, to completely remove any previous go installation — just to prevent any weird outcome.

Single-line Installation

IMPORTANT: Before you continue, I encourage you to read the install script; never trust someone telling you to run random commands.

That said, you can install g with a single command:

curl -sSL https://git.io/g-install | sh -s

If you use wget instead:

wget -qO- https://git.io/g-install | sh -s

That will download the g script, put it inside $GOPATH/bin/, give it execution rights with chmod, and configure your default shell's initialization file, setting the GOPATH & GOROOT environment variables and adding $GOPATH/bin to the PATH.

Then you will prompted to install the latest version of go; you can skip this step and install your preferred version with g later.

NOTE: You must restart your current shell session for it to read these new env vars in order to use g or go.

Shell support

The install script currently supports the following shells:

  • bash
  • zsh
  • fish
  • ash
  • dash
  • csh
  • tcsh

That doesn't mean you cannot use g with other shells, just proceed with the manual installation.

The install script is going to select your default shell for configuration. You might see what your default shell is by running:

echo $SHELL

If you wish to configure a diff shell, you might pass it as arguments:

curl -sSL https://git.io/g-install | sh -s -- fish

You might as well configure several shells, but that's usually not required:

curl -sSL https://git.io/g-install | sh -s -- fish bash zsh

Use the -y option to skip the prompts and assume "yes" for everything:

curl -sSL https://git.io/g-install | sh -s -- -y

Changing defaults

By default, these go environment variables are used:

GOROOT: $HOME/.go
GOPATH: $HOME/go

$GOPATH/bin is added to the PATH and there's where g is copied to.

You might set those variables before running the install script. For example, in bash and zsh:

export GOROOT=~/.local/share/golang
export GOPATH=~/MyProjects/go-projects
curl -sSL https://git.io/g-install | sh -s

In fish:

set -gx GOROOT ~/.local/share/golang
set -gx GOPATH ~/MyProjects/go-projects
curl -sSL https://git.io/g-install | sh -s

Manual Installation

  1. Make sure to export the $GOPATH & $GOROOT environment variables and add $GOPATH/bin to your PATH.
  2. Grab a copy of the ./bin/g script and put it anywhere available in your PATH — inside $GOPATH/bin/ is a good option.
  3. Give the script execution rights with chmod +x $GOPATH/bin/g.
  4. Restart your shell session to make sure the env variables are loaded.

Upgrading

g includes a self-upgrade command you can run to get the latest version of g. This command simply runs the install script once again.

Usage

  Usage: g [COMMAND] [options] [args]

  Commands:

    g                         Open interactive UI with downloaded versions
    g install latest          Download and set the latest go release
    g install <version>       Download and set go <version>
    g download <version>      Download go <version>
    g set <version>           Switch to go <version>
    g run <version>           Run a given version of go
    g which <version>         Output bin path for <version>
    g remove <version ...>    Remove the given version(s)
    g prune                   Remove all versions except the current version
    g list                    Output downloaded go versions
    g list-all                Output all available, remote go versions
    g self-upgrade            Upgrades g to the latest version
    g help                    Display help information, same as g --help

  Options:

    -h, --help                Display help information and exit
    -v, --version             Output current version of g and exit
    -q, --quiet               Suppress almost all output
    -c, --no-color            Force disabled color output
    -y, --non-interactive     Prevent prompts
    -o, --os                  Override operating system
    -a, --arch                Override system architecture
    -u, --unstable            Include unstable versions in list

Uninstall

g is a single portable shell script that acts like a binary that's available in your $PATH. If you setup g with the install script, its removal should be pretty straight forward.

First of all, get some info about your system:

echo $SHELL
echo $GOROOT
echo $GOPATH
command -v g

You will notice the g file lives inside your $GOPATH/bin/ directory. If you only want to remove g and keep your currently installed go binaries and related files, simply delete g:

# If you're using bash, zsh, or other POSIX shell:
rm "$(command -v g)"

# If you're using fish:
rm (command -v g)

Now, if you want to remove everything, first be sure to backup your projects inside $GOROOT, if any. Then remove everything inside $GOROOT and $GOPATH:

rm -r $GOPATH $GOROOT

Then open your shell config file with your text editor of choice and look of for a line that includes g-install to remove it. These are the locations usually used by the install script:

# bash on MacOS
~/.bash_profile

# bash on linux/BSD
~/.bashrc

# zsh
~/.zshrc

# fish shell
~/.config/fish/config.fish

# csh
~/.cshrc

# tcsh
~/.tcshrc

# For ash for dash, check your $ENV var
echo $ENV

At this point you would have removed g and go entirely.

TODO

  • [ ] Improve docs a bit more
  • [x] Make g and g-install POSIX compliant
  • [x] Add support for more shells
  • [x] Warn users they already have a golang installation when using g-install
  • [x] Use better naming for g install <version>, maybe use or set. See #8
    • [x] Use install only for install and remove the --download option
  • [x] Handle the case when g already exists, mainly zsh with oh-my-zsh
    • [x] Make it so g-install offers the user to setup an alternative alias for g
  • [x] Make the self-upgrade command throw if g was not installed in the common way
  • [ ] Add a complete command that generates completions for the supported shells
    • [ ] And have g-install setup the shells to call this command for completions
  • [ ] Explore feature to configure shells to autoload go versions based on a project file
  • [ ] Test it on diff platforms
  • [ ] Crete a test setup with docker and Github actions

The alternatives (and why I prefer g)

  • moovweb/gvm
    • Too many features.
    • Builds from source, i.e, requires gcc, make, xcode, etc.
    • Requires git and mercurial.
    • Requires bootstrapping, i.e., install go 1.4 first.
    • Specific to a shell, i.e., doesn't work with fishshell.
  • syndbg/goenv
    • Too many features and weird DX.
    • Uses an hard-coded list of go versions...
    • ...thus you have to upgrade goenv before installing a new version of go.
    • Adds a lot to your env and PATH.
  • hit9/oo
    • Pretty much same as gvm.
  • asdf-golang
  • andrewkroh/gvm
    • Bash, batch and powershell support only.
    • Cumbersome to use.
  • MakeNowJust/govm
    • Builds from source.
    • Requires python 2.

Contributing

Please read CONTRIBUTING.md. ♥

Acknowledgments

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].