|
| 1 | + |
| 2 | + |
| 3 | +# GoVM - Go Version Manager |
| 4 | + |
| 5 | +GoVM is a modern tool for managing multiple Go versions on your system. It features both a clean Terminal UI (TUI) and a command-line interface for easy installation and switching between Go versions. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- Beautiful TUI built with [Charm Bubbletea](https://github.com/charmbracelet/bubbletea) |
| 10 | +- Command-line interface for quick operations |
| 11 | +- Install any available Go version directly from go.dev |
| 12 | +- Switch between installed versions with a single command |
| 13 | +- Supports partial version numbers (e.g., `1.21` for latest 1.21.x) |
| 14 | +- Works on macOS and Linux. Looking for testing for Windows |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +### Prerequisites |
| 19 | + |
| 20 | +- Go 1.18 or higher |
| 21 | + |
| 22 | +### Install |
| 23 | + |
| 24 | +```bash |
| 25 | +go install github.com/melkeydev/govm@latest |
| 26 | +``` |
| 27 | + |
| 28 | +Then in a new terminal run: |
| 29 | + |
| 30 | +```bash |
| 31 | +govm |
| 32 | +``` |
| 33 | + |
| 34 | +To launch the TUI |
| 35 | + |
| 36 | +## First-Time Setup |
| 37 | + |
| 38 | +When you first run GoVM, it will guide you through adding the required directory to your PATH. This is a one-time setup that enables GoVM to manage your Go versions. |
| 39 | + |
| 40 | +### On Linux/macOS |
| 41 | + |
| 42 | +Add this to your shell configuration file (~/.bashrc, ~/.zshrc, etc.): |
| 43 | + |
| 44 | +```bash |
| 45 | +export PATH="$HOME/.govm/shim:$PATH" |
| 46 | +``` |
| 47 | + |
| 48 | +Or run this command to add it automatically: |
| 49 | + |
| 50 | +```bash |
| 51 | +echo 'export PATH="$HOME/.govm/shim:$PATH"' >> ~/.bashrc # or ~/.zshrc |
| 52 | +``` |
| 53 | + |
| 54 | +Then reload your shell configuration: |
| 55 | + |
| 56 | +```bash |
| 57 | +source ~/.bashrc # or whichever file you modified |
| 58 | +``` |
| 59 | + |
| 60 | +### On Windows |
| 61 | + |
| 62 | +Add the shim directory to your PATH: |
| 63 | + |
| 64 | +```cmd |
| 65 | +setx PATH "%USERPROFILE%\.govm\shim;%PATH%" |
| 66 | +``` |
| 67 | + |
| 68 | +Then restart your terminal. |
| 69 | + |
| 70 | +## Usage |
| 71 | + |
| 72 | +GoVM can be used in two ways: via the interactive TUI or through command-line commands. |
| 73 | + |
| 74 | +### Terminal User Interface (TUI) |
| 75 | + |
| 76 | +Launch the interactive TUI by running govm without arguments: |
| 77 | + |
| 78 | +```bash |
| 79 | +govm |
| 80 | +``` |
| 81 | + |
| 82 | +#### Navigation |
| 83 | + |
| 84 | +- Use the arrow keys to navigate through the list of versions |
| 85 | +- Press `i` to install the selected version |
| 86 | +- Press `u` to use/switch to the selected version |
| 87 | +- Press `r` to refresh the list of available versions |
| 88 | +- Press `Tab` to switch between "Available Versions" and "Installed Versions" views |
| 89 | +- Press `q` to quit |
| 90 | + |
| 91 | +### Command Line Interface |
| 92 | + |
| 93 | +```bash |
| 94 | +# Install a Go version (latest patch for the specified version) |
| 95 | +govm install 1.21 # Installs the latest Go 1.21.x |
| 96 | + |
| 97 | +# Switch to a Go version |
| 98 | +govm use 1.20 # Switches to the latest installed Go 1.20.x |
| 99 | + |
| 100 | +# List installed versions |
| 101 | +govm list |
| 102 | + |
| 103 | +# Show help |
| 104 | +govm help |
| 105 | + |
| 106 | +# Launch the TUI |
| 107 | +govm |
| 108 | +``` |
| 109 | + |
| 110 | +## How It Works |
| 111 | + |
| 112 | +GoVM downloads Go versions from the official go.dev website and installs them in `~/.govm/versions`. It uses a "shim" approach: |
| 113 | + |
| 114 | +- It creates wrapper scripts in `~/.govm/shim` that point to the selected Go version |
| 115 | +- When you run `go` or other Go commands, these wrappers execute the proper version |
| 116 | +- Switching versions simply updates these wrappers to point to a different installation |
| 117 | + |
| 118 | +This ensures a seamless experience without needing to manually update environment variables or source scripts each time you switch versions. |
| 119 | + |
| 120 | +### Install from source |
| 121 | + |
| 122 | +```bash |
| 123 | +# Clone the repository |
| 124 | +git clone https://github.com/melkeydev/govm.git |
| 125 | +cd govm |
| 126 | + |
| 127 | +# Build and install |
| 128 | +go build -o govm |
| 129 | +``` |
| 130 | + |
| 131 | +Then place the binary somewhere in your PATH. |
| 132 | + |
| 133 | +### Homebrew |
| 134 | + |
| 135 | +Add Homebrew repository to the system: |
| 136 | + |
| 137 | +```bash |
| 138 | +brew tap melkeydev/tap |
| 139 | +``` |
| 140 | + |
| 141 | +You can then install your package with: |
| 142 | + |
| 143 | +```bash |
| 144 | +brew install govm |
| 145 | +``` |
| 146 | + |
| 147 | +## Dependencies |
| 148 | + |
| 149 | +- [Charm Bubbletea](https://github.com/charmbracelet/bubbletea) - Terminal UI framework |
| 150 | +- [Charm Bubbles](https://github.com/charmbracelet/bubbles) - UI components |
| 151 | +- [Lipgloss](https://github.com/charmbracelet/lipgloss) - UI styling |
0 commit comments