Skip to content

Instantly share code, notes, and snippets.

@trevrosen
Last active October 20, 2015 02:06
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 trevrosen/ab458f865c33a871d02e to your computer and use it in GitHub Desktop.
Save trevrosen/ab458f865c33a871d02e to your computer and use it in GitHub Desktop.
A shell function to set up a Go project for contribution
# Set up a Go project for contribution. This setup gets around issues related to intra-package import paths
# $1 - the origin of the package, e.g. "github.com/spf13/hugo"
# $2 - the name of the package in the fork, e.g. "hugo"
#
export GITHUB_USERNAME="trevrosen"
gohack (){
echo "[-] Getting package $1"
go get $1
cd $GOPATH/src/$1
echo "[-] Creating fork environment for $2"
git remote rename origin upstream
git remote add origin git@github.com:$GITHUB_USERNAME/$2
git fetch --all
echo "[-] Setting up master"
git branch master --set-upstream-to origin/master
git checkout master
git checkout -b upstream-master --track upstream/master
echo "[-] Done!"
popd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment