Last active
December 18, 2015 23:08
-
-
Save rahulg/5859285 to your computer and use it in GitHub Desktop.
Initialise a golang project by setting up the directory structure and creating the virtualenv-like activate script.
This file contains 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
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: $(basename "${0}") <project>" | |
exit 1 | |
fi | |
mkdir -p "${1}"/{,src,pkg,bin} | |
cat << 'EOF' > "${1}/activate" | |
if [ -z "$BASH_VERSION" ]; then | |
export GOPATH="$(cd "$(dirname "${0}" )" && pwd)" | |
else | |
export GOPATH="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)" | |
fi | |
export OLDPS1=$PS1 | |
export PS1="[go:$(basename $GOPATH)] $PS1" | |
alias gcd="cd $GOPATH" | |
deactivate() { | |
export PS1=$OLDPS1 | |
unset GOPATH | |
unset OLDPS1 | |
unalias gcd | |
unset deactivate | |
} | |
EOF | |
cat << 'EOF' > "${1}/activate.fish" | |
set -x GOPATH (dirname (status -f)) | |
function gcd | |
cd $GOPATH | |
end | |
function deactivate | |
set -e GOPATH | |
functions -e deactivate | |
end | |
EOF | |
cat << 'EOF' > "${1}/$(basename "${1}").sublime-project" | |
{ | |
"folders": | |
[ | |
{ | |
"path": "." | |
} | |
], | |
"settings": { | |
"GoSublime": { | |
"env": { | |
"GOPATH": "$PWD" | |
} | |
} | |
} | |
} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/sidenote github's slightly screwed syntax highlighting makes me feel better about arc.