mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-21 18:46:06 +02:00
* Create go_prompt_info to add go version to prompts * golang: move go_prompt_info to plugin, guard and quote output Addresses review feedback: the prompt helper only belongs to Go developers, so it moves out of lib/ (sourced for every shell) into plugins/golang/golang.plugin.zsh. Adds a $+commands[go] guard so users without Go installed don't spawn a process or see a stderr error on every prompt render, quotes the version output the same way the rvm/nvm helpers do so a % can't be read as a prompt escape, and adds the dummy go_prompt_info stub to lib/prompt_info_functions.zsh for themes that call it when the plugin isn't loaded. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193G8TyNqmNnv6v9HsVafGa --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
3.1 KiB
3.1 KiB
Golang plugin
This plugin adds completion for the Go Programming Language, as well as some aliases for common Golang commands.
To use it, add golang to the plugins array in your zshrc file:
plugins=(... golang)
Aliases
| Alias | Command | Description |
|---|---|---|
| gob | go build |
Build your code |
| goc | go clean |
Removes object files from package source directories |
| god | go doc |
Prints documentation comments |
| goe | go env |
Prints Go environment information |
| gof | go fmt |
Gofmt formats (aligns and indents) Go programs. |
| gofa | go fmt ./... |
Run go fmt for all packages in current directory, recursively |
| gofx | go fix |
Update packages to use a new API |
| gog | go get |
Downloads packages and then installs them to $GOPATH |
| goga | go get ./... |
Installs all dependencies in current directory, recursively |
| goi | go install |
Compiles and installs packages to $GOPATH |
| gol | go list |
Lists Go packages |
| gom | go mod |
Access to operations on modules |
| gomt | go mod tidy |
Tidies up the go.mod file |
| gopa | cd $GOPATH |
Takes you to $GOPATH |
| gopb | cd $GOPATH/bin |
Takes you to $GOPATH/bin |
| gops | cd $GOPATH/src |
Takes you to $GOPATH/src |
| gor | go run |
Compiles and runs your code |
| got | go test |
Runs tests |
| gota | go test ./... |
Runs tests in all subdirectories |
| goto | go tool |
Prints all the available tools |
| gotoc | go tool compile |
Generates object file |
| gotod | go tool dist |
Utility to bootstrap, build and test go runtime |
| gotofx | go tool fix |
Fixes an application to use newer features |
| gov | go vet |
Vet examines Go source code and reports suspicious constructs |
| gove | go version |
Prints Go version |
| gow | go work |
Work provides access to operations on workspaces |
Prompt
This plugin provides the go_prompt_info function to add the installed Go
version to your prompt.
For example:
PROMPT="%~$ "
RPROMPT='$(go_prompt_info)'
changes your prompt to:
~/go/project$ ▋ 1.22.3