Skip to content

Instantly share code, notes, and snippets.

@songgao
Last active February 23, 2016 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save songgao/572a51f5883422a52f39 to your computer and use it in GitHub Desktop.
Save songgao/572a51f5883422a52f39 to your computer and use it in GitHub Desktop.
Shell functions for quickly `cd` into Go packages' source directories
gprefresh() {
go list -f "{{.Dir}}" ... 2>/dev/null > $GOPATH/.list;
}
_gpcd() {
if [ "$#" -eq 1 ]; then
cd $1
else
select p in $@; do
_gpcd $p
unset p
break
done
fi
}
gpcd() {
_gpcd $(echo $(grep --color=never '/'$1'$' "$GOPATH/.list"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment