]> git.giacomolli.uk - onechat/commitdiff
Check the width of comment lines master
authorAnderson A. Giacomolli <redacted>
Tue, 10 Nov 2026 20:48:48 +0000 (17:48 -0300)
committerAnderson A. Giacomolli <redacted>
Tue, 10 Nov 2026 20:48:48 +0000 (17:48 -0300)
bin/check fails on a Go comment line over 80 columns, counted as
bin/reflow counts them, with tabs as 8 columns. gofumpt does not wrap
comments, and the line length linter would also count code lines, which
the go-code skill keeps on one line, so ten long comment lines had
passed every check.

bin/check

index 73256cb682e87ad835add38947fa9e318ac5e4b0..e8e6e97ab96350c2812da6853c9d5ee82152188b 100755 (executable)
--- a/bin/check
+++ b/bin/check
@@ -13,6 +13,15 @@ if [ -n "$unformatted" ]; then
   exit 1
 fi
 
+# Comment lines stay within the width of bin/reflow, with tabs as 8 columns.
+long=$(files '*.go' | while read -r file; do
+  expand -t8 "$file" | awk -v file="$file" 'length > 80 && /^[[:space:]]*\/\//{print file ":" FNR}'
+done)
+if [ -n "$long" ]; then
+  printf 'comment lines over 80 columns, run bin/reflow:\n%s\n' "$long" >&2
+  exit 1
+fi
+
 go vet ./...
 golangci-lint run
 go test -race -short ./...