github.com/adecaro/fabric-ca@v2.0.0-alpha+incompatible/scripts/check_format (about) 1 #!/bin/bash 2 # 3 # Copyright IBM Corp. All Rights Reserved. 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 rc=0 8 9 echo "Checking file format ..." 10 found=$(gofmt -l `find . -path ./vendor -prune -o -type f -regex ".*.go" -print` 2>&1) 11 if [[ -n "$found" ]]; then 12 echo "The following files need reformatting with 'gofmt -w <file>':" 13 echo "$found" 14 let rc+=1 15 fi 16 17 echo "Checking for trailing blanks..." 18 find . -path ./vendor -prune -o -type f -regex ".*\(regenDocs\|\.\(go\|sh\)\)" \ 19 -exec egrep -q " +$" {} \; \ 20 -exec printf "trailing blanks in {}\n" \; | egrep ".*" 21 if test $? -eq 0; then 22 echo "To fix, run" 23 echo ' find . -path ./vendor -prune -o -type f -regex ".*\(regenDocs\|\.\(go\|sh\)\)" -exec sed -i "s/ \+$//" {} \;' 24 echo "" 25 let rc+=1 26 fi 27 28 test "$rc" -eq 0 || exit "$rc" 29 echo "All files are properly formatted"