hack/verify-gofmt.sh
1b64eb52
 #!/bin/bash
 
 # GoFmt apparently is changing @ head...
 
e3bb13a1
 set -o errexit
 set -o nounset
 set -o pipefail
 
1b64eb52
 GO_VERSION=($(go version))
 
9411aa8b
 if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.4|go1.5') ]]; then
581cc7e1
   echo "Unknown go version '${GO_VERSION}', skipping gofmt."
1b64eb52
   exit 0
 fi
 
e3bb13a1
 OS_ROOT=$(dirname "${BASH_SOURCE}")/..
 source "${OS_ROOT}/hack/common.sh"
6f45c69b
 source "${OS_ROOT}/hack/util.sh"
e3bb13a1
 
 cd "${OS_ROOT}"
 
 bad_files=$(find_files | xargs gofmt -s -l)
 if [[ -n "${bad_files}" ]]; then
   echo "!!! gofmt needs to be run on the following files: "
   echo "${bad_files}"
b4667870
   echo "Try running 'gofmt -s -d [path]'"
1b64eb52
   exit 1
 fi