From dbfd3918d30dcc9baafaff6ca998b6df3bf7c97a Mon Sep 17 00:00:00 2001 From: Mustafa Gezen Date: Sun, 30 Oct 2022 21:04:20 +0100 Subject: [PATCH] Output go fmt results to temp file and check if empty --- hack/gofmt_check.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hack/gofmt_check.sh b/hack/gofmt_check.sh index dec5f47..7edad12 100755 --- a/hack/gofmt_check.sh +++ b/hack/gofmt_check.sh @@ -8,7 +8,9 @@ $BAZEL_B @go_sdk//... export PATH="$(bazel info output_base)/external/go_sdk/bin:$PATH" -if [[ -z $(go fmt -n $(go list ./... | grep -v /vendor/) | sed 's/ -w//') ]]; then +$(go fmt -n $(go list ./... | grep -v /vendor/) | sed 's/ -w//') > /tmp/fmt + +if [[ -n "$(cat /tmp/fmt)" ]]; then echo "Go files must be formatted with gofmt. Please run:" echo ' go fmt $(go list ./... | grep -v /vendor/)' exit 1