Skip to content

Instantly share code, notes, and snippets.

@sharpner
Created August 14, 2015 09:32
Show Gist options
  • Save sharpner/7d255d7a3a81052a42b3 to your computer and use it in GitHub Desktop.
Save sharpner/7d255d7a3a81052a42b3 to your computer and use it in GitHub Desktop.
clone and symlink go open source project
#/!bin/bash
repository=github.com
if [ -z "$GOPATH" ] ; then
echo '$GOPATH not set.'
exit 1
fi
cd $GOPATH
if [ $# -lt 1 ] ; then
echo "Usage: goclone group/project [repository]"
exit 1
fi
if [ ! -z "$2" ] ; then
repository=$2
fi
group=`echo $1 | cut -f1 -d"/"`
project=`echo $1 | cut -f2 -d"/"`
if [ -z "$project" ] || [ -z "$group" ] ; then
echo "Usage: goclone group/project [repository]"
exit 1
fi
repo=$1
target=$GOPATH/src/$repository/$group
if [ ! -d $target ] ; then
mkdir -p $target
echo "Created folder "$target
fi
cd $target
git clone git@$repository:$repo.git
if [ $? -ne 0 ] ; then
echo "Could not clone repository"
exit 1
fi
symlink=$project
cd $GOPATH
ln -s $target/$project _$symlink
@mattn
Copy link

mattn commented Aug 16, 2015

you can use motemen/ghq.

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