Skip to content

Instantly share code, notes, and snippets.

@steder
Created September 9, 2017 02:03
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 steder/669225b7dc8a84d73c3027f054103f20 to your computer and use it in GitHub Desktop.
Save steder/669225b7dc8a84d73c3027f054103f20 to your computer and use it in GitHub Desktop.
Quickly jump to $GOPATH/src directory
#!/usr/bin/env bash
GOPATH=~/go/src
# Just include this function in your ~/.bashrc
function gof {
if (( $# == 0 )); then
echo "usage: $gof <dir>"
echo "jumps to $GOPATH/src directory matching <dir>"
return
fi
PKGDIR=$(find $GOPATH -type d -iname "$1" | sort | head -n 1)
if [[ -d $PKGDIR ]]; then
cd $PKGDIR
else
echo "No go path in $GOPATH matching $1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment