quintodrome/bin/fmt.sh

14 lines
306 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2016-03-07 10:38:43 -09:00
gofmtcmd=`which goimports || echo "gofmt"`
gofiles=$(git diff --name-only --diff-filter=ACM | grep '.go$')
[ -z "$gofiles" ] && exit 0
2016-03-07 10:38:43 -09:00
unformatted=`$gofmtcmd -l $gofiles`
[ -z "$unformatted" ] && exit 0
for f in $unformatted; do
2016-03-07 10:38:43 -09:00
$gofmtcmd -w -l "$f"
2016-03-14 07:36:11 -08:00
gofmt -s -w -l "$f"
done