distribution/hack/validate_gofmt.sh

19 lines
423 B
Bash
Raw Normal View History

2014-11-07 23:45:51 +00:00
#!/bin/bash
badFiles=($(find ./ -iname "*.go" -exec gofmt -s -l {} \;))
if [ ${#badFiles[@]} -eq 0 ]; then
echo 'Congratulations! All Go source files are properly formatted.'
else
{
echo "These files are not properly gofmt'd:"
for f in "${badFiles[@]}"; do
echo " - $f"
done
echo
echo 'Please reformat the above files using "gofmt -s -w" and commit the result.'
echo
} >&2
false
fi