fix(template): ship a go.sum, and stop the templ generator drifting from the library

Closes #8.

`task check` did not pass on a clean checkout of this template, and had not
for some time. Three defects in a chain, each hiding the next:

1. No go.sum at all. `go build ./...` failed on missing sum entries, so
   nothing downstream of it ever ran.

2. With that fixed, the real skew appeared: CI installs the templ GENERATOR
   as @latest while go.mod pinned the templ LIBRARY at v0.2.778. The v0.3
   generator emits calls to templruntime.WriteString, which v0.2.778 does not
   have -- so generated code could not compile against the pinned runtime.
   Library moved to v0.3.1020 and the CI install now derives its version from
   go.mod, so generator and library cannot drift apart again.

3. .gitignore carried `*.templ.go`. templ writes `<name>_templ.go` -- an
   underscore, not a dot -- so the pattern matched nothing. Generated files
   were kept out of git by luck rather than by the ignore rule.

None of this was visible from this repo's CI, which has been green
throughout, because the guard job skips `check` here entirely (#12). A
template whose gate cannot run is a template whose defects are found by its
children.

Verified on a clean checkout: `go build ./...` clean, `task check` exit 0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 18:04:13 +02:00
co-authored by Claude Opus 5
parent b9bbbae3bb
commit b40db025cc
4 changed files with 17 additions and 5 deletions
+8 -1
View File
@@ -48,7 +48,14 @@ jobs:
- name: Install toolchain
run: |
go version
go install github.com/a-h/templ/cmd/templ@latest
# Pin the GENERATOR to the same version as the templ LIBRARY in
# go.mod. Installing @latest let them drift: the generator emitted
# calls (templruntime.WriteString) that the pinned library did not
# have, which is template-go-web#8. Nothing caught it because the
# guard skipped `check` in this repo entirely (#12).
templ_version="$(go list -m -f '{{.Version}}' github.com/a-h/templ)"
echo "templ library is $templ_version — installing the matching generator"
go install "github.com/a-h/templ/cmd/templ@$templ_version"
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh \
| sh -s -- -b "$(go env GOPATH)/bin" v2.11.4
+4 -1
View File
@@ -27,4 +27,7 @@ go.work.sum
# Project-specific
bin/
*.templ.go
# templ writes <name>_templ.go -- this was '*.templ.go' (a dot, not an
# underscore) and therefore matched nothing, so generated files were only ever
# kept out of git by luck. template-go-web#8.
*_templ.go
+1 -3
View File
@@ -2,6 +2,4 @@ module __MODULE_PATH__
go 1.26
require (
github.com/a-h/templ v0.2.778
)
require github.com/a-h/templ v0.3.1020
+4
View File
@@ -0,0 +1,4 @@
github.com/a-h/templ v0.3.1020 h1:ypAT/L5ySWEnZ6Zft/5yfoWXYYkhFNvEFOeeqecg4tw=
github.com/a-h/templ v0.3.1020/go.mod h1:A2DlK61v+K+NRoGnhmYbNYVmtYHcFO5/AisMvBdDxTM=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=