set -euo pipefail

go fmt ./...

set +e
changes=$(git status -s | grep ".go$" | awk '{print $2}')
set -e

if [[ "$changes" != "" ]]; then
    # Some go files are not formatted.
    echo "Your commit is changed after running 'go fmt ./...'."
    echo "You must format your code before submitting a PR."
    exit 1
fi
