Note: This is a fork of a-h/templ adapted for Go 1.24
The
go1.24branch downgrades the Go version requirement from 1.25 to 1.24 and fixes related compatibility issues.
See user documentation at https://templ.guide
International (GitHub):
go get github.com/tekintian/templ@go1.24China Mainland (Gitee - faster access):
go get gitee.com/tekintian/templ@go1.24Or use replace in your go.mod:
require github.com/a-h/templ v0.3.833
// International
replace github.com/a-h/templ => github.com/tekintian/templ go1.24
// China Mainland
replace github.com/a-h/templ => gitee.com/tekintian/templ go1.24This branch makes the following modifications to support Go 1.24:
- Go version downgrade:
go 1.25.0→go 1.24.0 - Dependency downgrade:
golang.org/x/*packages downgraded to Go 1.24 compatible versions - Syntax fixes:
sync.WaitGroup.Go()(Go 1.25+) → traditionalgo func() + wg.Add/Donefor range N(Go 1.25+) →for i := 0; i < N; i++
| Branch | Go Version | Description |
|---|---|---|
main |
1.25+ | Upstream original version |
go1.24 |
1.24+ | This branch, Go 1.24 compatible version |
Set the version of templ to the current version.
version set --template="0.3.%d"Build a local version.
version set --template="0.3.%d"
cd cmd/templ
go buildBuild and install current version.
# Remove templ from the non-standard ~/bin/templ path
# that this command previously used.
rm -f ~/bin/templ
# Clear LSP logs.
rm -f cmd/templ/lspcmd/*.txt
# Update version.
version set --template="0.3.%d"
# Install to $GOPATH/bin or $HOME/go/bin
cd cmd/templ && go installUse goreleaser to build the command line binary using goreleaser.
goreleaser build --snapshot --cleanRun templ generate using local version.
go run ./cmd/templ generate -include-version=falseRun Go tests.
version set --template="0.3.%d"
go run ./cmd/templ generate -include-version=false
go test ./...Run Go tests.
version set --template="0.3.%d"
go run ./cmd/templ generate -include-version=false
go test ./... -shortRun Go tests.
# Create test profile directories.
mkdir -p coverage/fmt
mkdir -p coverage/generate
mkdir -p coverage/version
mkdir -p coverage/unit
# Build the test binary.
go build -cover -o ./coverage/templ-cover ./cmd/templ
# Run the covered generate command.
GOCOVERDIR=coverage/fmt ./coverage/templ-cover fmt .
GOCOVERDIR=coverage/generate ./coverage/templ-cover generate -include-version=false
GOCOVERDIR=coverage/version ./coverage/templ-cover version
# Run the unit tests.
go test -cover ./... -coverpkg ./... -args -test.gocoverdir="$PWD/coverage/unit"
# Display the combined percentage.
go tool covdata percent -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit
# Generate a text coverage profile for tooling to use.
go tool covdata textfmt -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit -o coverage.out
# Print total
go tool cover -func coverage.out | grep totalinteractive: true
gotestsum --watch -- -coverprofile=coverage.out./parser/v2/fuzz.sh
./parser/v2/goexpression/fuzz.shRun benchmarks.
go run ./cmd/templ generate -include-version=false && go test ./... -bench=. -benchmemFormat all Go and templ code.
gofmt -s -w .
go run ./cmd/templ fmt .Run the lint operations that are run as part of the CI.
golangci-lint run --verboseEnsure that templ files have been generated with the local version of templ, and that those files have been added to git.
Requires: generate
git diff --exit-codePush a semantic version number to GitHub to trigger the release process.
version push --template="0.3.%d" --prefix="v"Run the development server.
Directory: docs
npm run startBuild production docs site.
Directory: docs
npm run build
