Go Get Zsh Autocomplete
'go get' zsh command completion based on already locally fetched packages in the GOMODCACHE and git ls-remote versions
Install / Use
npx skills add Emptyless/go-get-zsh-autocompleteInstalls into whichever agent you are using.
README
'go get' zsh autocompletions
Inspired by spf13/cobra completions, this
repo reproduces similar autocompletions for the 'go get' command based on already locally fetched
packages in the GOMODCACHE and uses git ls-remote to fetch possible versions for those packages.
No issues were found during local development and or local usage but your mileage may vary. The author(s) are not responsible for any issues that you may encounter or results thereof when using resources from this repository. Usage is 100% at own risk. Submit issues to the Github issue tracker if found.
Getting Started
Ensure that Z Shell (zsh) and Go are installed, e.g. on linux with apt:
apt install zsh
apt install golang
Or on Mac with (using Brew):
brew install zsh
brew install go
Commpletions are based on the GOMODCACHE location, if go was just installed, verify this location
using go env GOMODCACHE
To use ZSH autocompletions, the autocompletion system must have been initialized. If not, ensure that the
following is part of your ~/.zshrc
autoload -Uz compinit
compinit
Install the completions using 1 of 2 methods:
- by appending the file to some
$fpath, e.g. in~/.zshrc:
git clone https://github.com/Emptyless/go-zsh-autocomplete
echo "" >> ~/.zshrc
cat go-zsh-autocomplete/_go-zsh-autocomplete.zsh >> ~/.zshrc
- by referencing the _go-zsh-autocomplete.zsh file
git clone https://github.com/Emptyless/go-zsh-autocomplete
echo "" >> ~/.zshrc
echo -n "source " >> ~/.zshrc
pwd | tr -d '\n' >> ~/.zshrc
echo "go-zsh-autocomplete/_go-zsh-autocomplete.zsh" >> ~/.zshrc
echo "" >> ~/.zshrc
Source the zshrc:
source ~/.zshrc
And now for any package that is in the GOMODCACHE (see go env GOMODCACHE), autocompletion is enabled:
go get github<tab>
will display all locally cached Github packages. For some <user> and <repo>, fetch the tags and branches using:
go get github.com/<user>/<repo>@<tab>
which will display all possible branches and tags to use for go get
Oh My ZSH
When using Oh My Zsh, there is a recommended location to store completions:
git clone github.com/Emptyless/go-zsh-autocomplete
echo '#!/bin/sh\n' > ~/.oh-my-zsh/completions/_go-zsh-autocomplete.zsh
cat ./go-zsh-autocomplete/_go-zsh-autocomplete.zsh >> ~/.oh-my-zsh/completions/_go-zsh-autocomplete.zsh
chmod +x ~/.oh-my-zsh/completions/_go-zsh-autocomplete.zsh
Debugging
Ensure that the $ZSH_GO_COMP_DEBUG_FILE variable is set to some filepath, e.g.
export ZSH_GO_COMP_DEBUG_FILE=debug.txt
go get github.com/<tab>
Development
Add the zsh shebang before development and set the debug variable
#!/bin/zsh
export ZSH_GO_COMP_DEBUG_FILE=debug.txt
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
blender-python-addon
40.5kBlender Python add-on rules for operators, panels, properties, registration, testing, and API-safe scripting
flutter-development-guidelines-cursorrules-prompt-file
40.5kCursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.
commit-push-pr
140.6kCommit, push, and open a PR
