Created
September 9, 2017 02:03
-
-
Save steder/669225b7dc8a84d73c3027f054103f20 to your computer and use it in GitHub Desktop.
Quickly jump to $GOPATH/src directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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