Skip to content

Instantly share code, notes, and snippets.

@farnasirim
Last active November 2, 2017 09:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farnasirim/fa4f7ab61a6944e214df6b9fd6525cd9 to your computer and use it in GitHub Desktop.
Save farnasirim/fa4f7ab61a6944e214df6b9fd6525cd9 to your computer and use it in GitHub Desktop.
navigate to a go project directory easily using `goto` command
#!/bin/bash
if [ -z "$@" ]; then
echo "Usage: goto project-name"
return
fi
search_path=$GOPATH/src/
for i in {1..3}; do
len=${#search_path}
project_dir=$(find $GOPATH/src -maxdepth $i -mindepth $i | cut -c$len- | grep -m 1 $1)
if [ ! -z "$project_dir" ] ; then
cd $search_path/$project_dir
break
fi
done
@arastu
Copy link

arastu commented Jul 15, 2017

Very helpful 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment