#!/bin/sh
FILES="$( find . -name '*.go' -print0 | xargs -0 gofmt -l )"
if [ -n "$FILES" ]; then
    echo -e "go fmt diff in:\n$FILES"
    exit 1
fi

#!/bin/bash
FILES="$( find . -name '*.go' -print0 | xargs -0 gofmt -l )"
if [ -n "$FILES" ]; then
    echo "go fmt diff found."
    echo "Run the following command in the git repo root to fix the formatting:"
    echo "gofmt -w $( echo "$FILES" | tr '\n' ' ' )"
    exit 1
fi

Use /bin/bash (/bin/sh behavior is different from bash when handling "-e" cmdline flag). More verbose error message.
Use /bin/bash (/bin/sh behavior is different from bash when handling
"-e" cmdline flag). More verbose error message.
