Skip to content

Instantly share code, notes, and snippets.

@joshua
Created September 19, 2017 00:38
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 joshua/33794cb0a00e0346e8ae7eda63e8270c to your computer and use it in GitHub Desktop.
Save joshua/33794cb0a00e0346e8ae7eda63e8270c to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
find_files() {
find . -not \( \
\( \
-wholename '*/vendor/*' \
\) -prune \
\) -name '*.go'
}
GOFMT="gofmt -s"
bad_files=$(find_files | xargs $GOFMT -l)
if [[ -n "${bad_files}" ]]; then
echo "!!! '$GOFMT' needs to be run on the following files: "
echo "${bad_files}"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment