test-go-fmt 454 Bytes
Newer Older
Jakub Sztandera's avatar
Jakub Sztandera committed
1 2 3
#!/usr/bin/env bash
set -euo pipefail
T="$(mktemp)"
4 5 6
find . \
    -path ./test/sharness -prune \
 -o -path ./plugin/loader/preload.go -prune \
7
 -o -name '*.go' -print0 | xargs -0 gofmt -s -l > "$T"
Jakub Sztandera's avatar
Jakub Sztandera committed
8 9 10 11 12 13 14 15 16 17 18

if [ -n "$(cat $T)" ]; then
	echo "Following Go code is not formatted."
	echo "-----------------------------------"
	cat "$T"
	echo "-----------------------------------"
	echo "Run 'go fmt ./...' in your source directory"
	rm -f "$T"
	exit 1
fi
rm -f "$T"