diff --git a/fmt.sh b/fmt.sh new file mode 100755 index 0000000..7f07972 --- /dev/null +++ b/fmt.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Custom formatter following project guidelines: +# 1. Standard gofmt +# 2. 2-space indentation (expand tabs) +# 3. Report/Check 112-char limit + +FILES=$(find . -name "*.go" -not -path "./bin/*") + +for f in $FILES; do + gofmt -s -w "$f" + expand -t 2 "$f" > "$f.tmp" && mv "$f.tmp" "$f" +done + +LONG_LINES=$(grep -n '.\{113,\}' $FILES) +if [ -n "$LONG_LINES" ]; then + echo "Warning: The following lines exceed 112 characters:" + echo "$LONG_LINES" +fi