| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | T="$(mktemp)" |
| 4 | find . \ |
| 5 | -path ./test/sharness -prune \ |
| 6 | -o -path ./plugin/loader/preload.go -prune \ |
| 7 | -o -name '*.go' -print0 | xargs -0 gofmt -s -l > "$T" |
| 8 | |
| 9 | if [ -n "$(cat $T)" ]; then |
| 10 | echo "Following Go code is not formatted." |
| 11 | echo "-----------------------------------" |
| 12 | cat "$T" |
| 13 | echo "-----------------------------------" |
| 14 | echo "Run 'gofmt -s -w .' in your source directory" |
| 15 | rm -f "$T" |
| 16 | exit 1 |
| 17 | fi |
| 18 | rm -f "$T" |