From de969c915538a0e3ed90f80688d7488eed32903d Mon Sep 17 00:00:00 2001 From: tannevaled Date: Sun, 4 Oct 2026 21:35:45 +0200 Subject: [PATCH] go.mod: require 1.27.1, and add the gofmt check this lane never had MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two things, and the second is why the first was worth doing here. THE TOOLCHAIN. `.github/workflows/ci.yml` has pinned `go-version: "1.27.1"` while `go.mod` asked for `go 1.26.4`. The directive now matches the pin, which matters because 1.27 counts statements more finely: a coverage figure measured with an older toolchain is an upper bound rather than a measurement, and this repository's gate is EXACT 100%. Measured with 1.27.1: still exactly 100%, every function, so the gate is unaffected. THE MISSING CHECK. `gofmt -l .` reported TWO files on main -- under 1.26's gofmt and 1.27's alike -- and nothing said so, because this lane runs `go vet` and no gofmt check while every sibling repository in the fleet runs both. An unformatted tree had been green for as long as it took to notice. The lane has the check now, in the same shape the siblings use, and the two files are formatted. One of them needed a judgement call rather than a mechanical rewrite: `font_test.go` built name-table records as "w.u16(3); w.u16(1); …", six calls on one line, which gofmt splits into six lines and which loses the one thing that layout was for -- a record is six numbers in a fixed order and reads as a row. A variadic `u16s` keeps the row and satisfies gofmt, which seemed better than making the file obey the tool at the cost of what it was showing. Verified with 1.27.1 before committing: gofmt, vet, `go test -race`, the exact-100% coverage gate, and the six cross-build targets the lane lists (including loong64, which is BUILT and never executed here -- so `golang/go#81147`, the loong64 code-generation backport still open at the 1.27.2 milestone, cannot affect this repository). A measurement note for whoever runs this next: the shared build cache on this machine was being pruned concurrently, which made `go test` fail twice with missing cache files and once with "package internal/nettrace is not in std". Neither was real; a private GOCACHE made every run reproducible. Co-Authored-By: Claude Opus 5 --- .github/workflows/ci.yml | 12 ++++++++++++ font_test.go | 6 +++--- go.mod | 2 +- synth_test.go | 9 +++++++++ units.go | 10 +++++----- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7de8c32..0724ac4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,18 @@ jobs: - name: qpdf, the independent oracle for what we write run: sudo apt-get update -qq && sudo apt-get install -y -qq qpdf + # The check this lane never had. The tree was unformatted on main -- two + # files, under both 1.26's gofmt and 1.27's -- and nothing said so, because + # every sibling repository in the fleet checks gofmt and this one did not. + - name: Gofmt + run: | + out=$(gofmt -l .) + if [ -n "$out" ]; then + echo "gofmt needs to be run on:" + echo "$out" + exit 1 + fi + - name: go vet run: go vet ./... diff --git a/font_test.go b/font_test.go index bcc9be3..6305e33 100644 --- a/font_test.go +++ b/font_test.go @@ -88,11 +88,11 @@ func TestReadPSNameEdgeCases(t *testing.T) { w.u16(3) // count (claims 3 records) w.u16(uint16(6 + 3*12)) // storage offset // record 0: nameID 1 (skipped) - w.u16(3); w.u16(1); w.u16(0); w.u16(1); w.u16(4); w.u16(0) + w.u16s(3, 1, 0, 1, 4, 0) // record 1: nameID 6, platform 0 (Unicode UTF-16BE) "Uni" - w.u16(0); w.u16(3); w.u16(0); w.u16(6); w.u16(6); w.u16(0) + w.u16s(0, 3, 0, 6, 6, 0) // record 2: nameID 6 but offset/length out of range (skipped) - w.u16(1); w.u16(0); w.u16(0); w.u16(6); w.u16(0xffff); w.u16(0xffff) + w.u16s(1, 0, 0, 6, 0xffff, 0xffff) storage := []byte{0, 'U', 0, 'n', 0, 'i'} w.b = append(w.b, storage...) if s := readPSName(w.b); s != "Uni" { diff --git a/go.mod b/go.mod index 5008b66..0cb037f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/go-pdfkit/pdfkit -go 1.26.4 +go 1.27.1 require github.com/go-opentype/opentype v0.13.0 diff --git a/synth_test.go b/synth_test.go index d83fbc5..193bc8b 100644 --- a/synth_test.go +++ b/synth_test.go @@ -84,6 +84,15 @@ type bw struct{ b []byte } func (w *bw) u8(v uint8) { w.b = append(w.b, v) } func (w *bw) u16(v uint16) { w.b = binary.BigEndian.AppendUint16(w.b, v) } + +// u16s writes several big-endian uint16s, for a record whose fields read better on +// ONE line -- a name-table record is six numbers in a fixed order, and gofmt splits +// "w.u16(3); w.u16(1); …" into six lines, which hides that shape. +func (w *bw) u16s(vs ...uint16) { + for _, v := range vs { + w.u16(v) + } +} func (w *bw) u32(v uint32) { w.b = binary.BigEndian.AppendUint32(w.b, v) } func (w *bw) i16(v int16) { w.u16(uint16(v)) } diff --git a/units.go b/units.go index a774abe..d1b7d57 100644 --- a/units.go +++ b/units.go @@ -44,11 +44,11 @@ func (s PageSize) Portrait() PageSize { // Standard ISO 216 A-series and US page sizes, in points. var ( - A3 = PageSize{Width: Mm(297), Height: Mm(420)} - A4 = PageSize{Width: Mm(210), Height: Mm(297)} - A5 = PageSize{Width: Mm(148), Height: Mm(210)} - Letter = PageSize{Width: In(8.5), Height: In(11)} - Legal = PageSize{Width: In(8.5), Height: In(14)} + A3 = PageSize{Width: Mm(297), Height: Mm(420)} + A4 = PageSize{Width: Mm(210), Height: Mm(297)} + A5 = PageSize{Width: Mm(148), Height: Mm(210)} + Letter = PageSize{Width: In(8.5), Height: In(11)} + Legal = PageSize{Width: In(8.5), Height: In(14)} Tabloid = PageSize{Width: In(11), Height: In(17)} )