Prefer using goimports over gofmt

This commit is contained in:
Deluan
2016-03-07 14:38:43 -05:00
parent 28bef732cf
commit df9687bf02
2 changed files with 32 additions and 2 deletions
+4 -2
View File
@@ -1,11 +1,13 @@
#!/usr/bin/env bash
gofmtcmd=`which goimports || echo "gofmt"`
gofiles=$(git diff --name-only --diff-filter=ACM | grep '.go$')
[ -z "$gofiles" ] && exit 0
unformatted=$(gofmt -l $gofiles)
unformatted=`$gofmtcmd -l $gofiles`
[ -z "$unformatted" ] && exit 0
for f in $unformatted; do
go fmt "$f"
$gofmtcmd -w -l "$f"
done