Skip to content

Instantly share code, notes, and snippets.

@lleveque
Last active December 13, 2016 20:55
Show Gist options
  • Save lleveque/d915f491baff7e5fa45e206b9b3e61c0 to your computer and use it in GitHub Desktop.
Save lleveque/d915f491baff7e5fa45e206b9b3e61c0 to your computer and use it in GitHub Desktop.
When in your $GOPATH, make `go` autocomplete to packages. Add this to your .bashrc.
function _gocomplete_()
{
# What do we want to autocomplete ?
local word=${COMP_WORDS[COMP_CWORD]}
# list packages that match in src/ subfolder, discarding warnings if no result
COMPREPLY=($(go list ./src/"${word}"... 2>/dev/null))
}
# register autocomplete function for `go`
complete -F _gocomplete_ go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment