#!/bin/bash
set -e

bin=$(dirname $0)

if [ $# -eq 0 ]; then
  gofiles="$($bin/gofiles)"
else
  gofiles="$1"
fi

unformatted_files=$(gofmt -l ${gofiles})
[ -z "$unformatted_files" ] && exit 0

echo -e "\nGo files are not formatted... "
for file in ${unformatted_files}; do
	echo "$file"
done

echo -e "\nYou can run '<project_root_dir>/bin/gofmt' to format all files."

echo
exit 1
