Skip to content

Commit

Permalink
Prefer gofumpt before gofmt
Browse files Browse the repository at this point in the history
Signed-off-by: Knut Ahlers <knut@ahlers.me>
  • Loading branch information
Luzifer committed Aug 8, 2020
1 parent b9d7e8e commit 467a2b8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/gofmtimport
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ set -euxo pipefail

[ ${DEBUG:-0} -eq 1 ] && exec 2>/tmp/gofmtimport.dbg

goimports \
cmdimports=$(command -v gofumports || command -v goimports || true)
cmdfmt=$(command -v gofumpt || command -v gofmt || true)

[[ -n $cmdimports ]] && [[ -n $cmdfmt ]] || {
echo "No imports command or no fmt command found" >&2
exit 1
}

${cmdimports} \
-srcdir "$2" \
-local "${GOIMPORT_LOCAL:-}" \
-w "$2"
gofmt -s -w "$2"
${cmdfmt} -s -w "$2"

0 comments on commit 467a2b8

Please sign in to comment.