Template
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user