#!/bin/sh # script/fmt-check: check formatting (read-only). Same scope as # script/fmt, but fails instead of writing. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" # script/bootstrap installs goimports into Go's bin directory, which # need not be on PATH. gobin="$(go env GOBIN)" [ -n "$gobin" ] || gobin="$(go env GOPATH)/bin" PATH="$gobin:$PATH" files="$(gofmt -s -l .; goimports -l .)" if [ -n "$files" ]; then echo "files that make fmt would change:" >&2 echo "$files" | sort -u >&2 exit 1 fi } main "$@"