Sfoglia il codice sorgente

Make gofmt -s part of checkstyle-go.sh and the style target in Makefile.

Also fix the comment in checkstyle-go.sh, it got the behavior of go{imports fmt}
-d the other way around.
Qi Xiao 2 anni fa
parent
commit
7d2130141b
2 ha cambiato i file con 6 aggiunte e 5 eliminazioni
  1. 1 0
      Makefile
  2. 5 5
      tools/checkstyle-go.sh

+ 1 - 0
Makefile

@@ -31,6 +31,7 @@ cover:
 # Ensure the style of Go and Markdown source files is consistent.
 style:
 	find . -name '*.go' | xargs goimports -w
+	find . -name '*.go' | xargs gofmt -s -w
 	find . -name '*.md' | xargs prettier --tab-width 4 --prose-wrap always --write
 
 # Check if the style of the Go and Markdown files is correct without modifying

+ 5 - 5
tools/checkstyle-go.sh

@@ -3,13 +3,13 @@
 # Check if the style of the Go source files is correct without modifying those
 # files.
 
-# The grep is because `goimports -d` will exit with a non-zero status even
-# when it doesn't suggest any changes. The grep will return failure if there
-# is no output from goimports and sucess if there are any proposed changes.
+# The grep is needed because `goimports -d` and `gofmt -d` always exits with 0.
 
 echo 'Go files need these changes:'
-if find . -name '*.go' | xargs goimports -d | grep .
-then
+if find . -name '*.go' | xargs goimports -d | grep .; then
+    exit 1
+fi
+if find . -name '*.go' | xargs gofmt -s -d | grep .; then
     exit 1
 fi
 echo '  None!'