3 export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4 source "${SCRIPTDIR}/.validate"
7 files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' |
9 grep -v '\.pb\.go$' || true) )
13 for f in "${files[@]}"; do
14 # we use "git show" here to validate that what's committed is formatted
15 if [ "$(git show "$VALIDATE_HEAD:$f" | gofmt -s -l)" ]; then
20 if [ ${#badFiles[@]} -eq 0 ]; then
21 echo 'Congratulations! All Go source files are properly formatted.'
24 echo "These files are not properly gofmt'd:"
25 for f in "${badFiles[@]}"; do
29 echo 'Please reformat the above files using "gofmt -s -w" and commit the result.'