Output go fmt results to temp file and check if empty

This commit is contained in:
Mustafa Gezen 2022-10-30 21:04:20 +01:00
parent 7facaddd48
commit dbfd3918d3
Signed by untrusted user who does not match committer: mustafa
GPG Key ID: DCDF010D946438C1
1 changed files with 3 additions and 1 deletions

View File

@ -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