Last active
July 10, 2020 14:16
-
-
Save carolynvs/11227e93d4c6080b72440c55f635a98b to your computer and use it in GitHub Desktop.
Find a go project in your GOPATH, written by @steder
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 | |
# Just source this file or copy/paste this function in your ~/.bashrc or ~/.bash_profile | |
function gof { | |
if (( $# == 0 )); then | |
echo "usage: $gof <dir>" | |
echo "jumps to $GOPATH/src directory matching <dir>" | |
return | |
fi | |
GOPATH=${GOPATH:-~/go} | |
PKGDIR=$(find $GOPATH/src -type d -maxdepth 3 -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