Skip to content

Instantly share code, notes, and snippets.

@zekroTJA
Created April 19, 2019 17:09
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 zekroTJA/18f8cf0028e7b9b2ee4354c9f117c0b1 to your computer and use it in GitHub Desktop.
Save zekroTJA/18f8cf0028e7b9b2ee4354c9f117c0b1 to your computer and use it in GitHub Desktop.
Setup script for go projects
#!/bin/bash
DIRS=(
"assets"
"build"
"cmd"
"config"
"docs"
"internal"
"pkg"
"scripts"
"test"
"web"
)
DEP_INSTALLED=false
GITIGNORE=https://raw.githubusercontent.com/github/gitignore/master/Go.gitignore
which dep &> /dev/null && {
DEP_INSTALLED=true
}
[ -d ./.git ] || {
echo "-> Initializing git repository"
git init
}
$DEP_INSTALLED && ! [ -f Gopkg.toml ] && {
echo "-> Initializing dep"
dep init
}
for dir in ${DIRS[*]}; do
[ -d $dir ] || {
echo "-> Creating dir '$dir'"
mkdir -p $dir
}
echo "" >> $dir/.keep
done
[ -f .gitignore ] || {
echo "-> Downloading .gitignore"
curl -o .gitignore $GITIGNORE
echo "-> Appending extras to .gitignore"
echo "" >> .gitignore
echo "# EXTRA STUFF" >> .gitignore
echo "private.*" >> .gitignore
echo "*.lock" >> .gitignore
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment