Created
April 19, 2019 17:09
-
-
Save zekroTJA/18f8cf0028e7b9b2ee4354c9f117c0b1 to your computer and use it in GitHub Desktop.
Setup script for go projects
This file contains hidden or 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 | |
| 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