github.com/cloudwego/hertz@v0.9.3/script/go-fmt (about) 1 #!/bin/bash 2 3 main() { 4 files=$(git diff --staged --diff-filter=ACMR --name-only) 5 go_files=() 6 for file in $files; do 7 ext=${file##*.} 8 if [ "$ext" != "go" ]; then 9 continue 10 fi 11 gofumpt -w "$file" 12 go_files+=("$file") 13 done 14 add_files=$(printf " %s" "${go_files[@]}") 15 add_files=${add_files:1} 16 17 if [ -n "$add_files" ]; then 18 git add $add_files 19 fi 20 } 21 22 main