Skip to content

Commit 9920fea

Browse files
committed
Fixed the issue with formatting issues not being reported when verification fails.
1 parent 1168552 commit 9920fea

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

hack/verify-gofmt.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ find_files() {
4848
\) -name '*.go'
4949
}
5050

51-
diff=$(find_files | xargs ${gofmt} -d -s 2>&1)
51+
# gofmt exits with non-zero exit code if it finds a problem unrelated to
52+
# formatting (e.g., a file does not parse correctly). Without "|| true" this
53+
# would have led to no useful error message from gofmt, because the script would
54+
# have failed before getting to the "echo" in the block below.
55+
diff=$(find_files | xargs ${gofmt} -d -s 2>&1) || true
5256
if [[ -n "${diff}" ]]; then
5357
echo "${diff}"
5458
exit 1

0 commit comments

Comments
 (0)