Introducing GoFast — build-time code generation for validation
and OpenAPI, benchmarked against Huma
Hi Gophers,
I’d like to share GoFast, a framework that generates request
validation, path/query binding, and OpenAPI documentation at
build time — via go/ast parsing, not runtime reflection.
What makes it different
Huma already does FastAPI-style automatic validation and OpenAPI
generation for Go, and it’s a mature, well-adopted project. GoFast
tests a narrower, specific bet: what if that same automation cost
nothing at request time, because the work happens once, at build
time, as real Go files committed to your own repo?
type LoginInput struct {
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,min=8"`
}
gofast generate ./main.go writes a real main_validate.gen.go
next to your code — readable, auditable, no hidden framework
machinery.
Benchmarked, not assumed
I measured GoFast against Huma v2.39.1 at four levels: isolated
validation, complex nested structs, full HTTP request cycle, and
concurrent throughput. Full methodology, hardware, and exact
reproduction commands are in docs/BENCHMARKS.md.
Isolated validation: ~37.5x faster, 0 allocations vs 3
Full HTTP cycle: ~1.49x faster — the isolated advantage narrows
sharply once JSON decoding and net/http overhead (identical cost
for both frameworks) dominate the budget
Concurrent load: ~1.05x — nearly equal once Go’s own scheduler/GC
dominate
CPU profiling confirms this: in the full HTTP cycle, GoFast’s
generated code doesn’t appear in the top 15 CPU consumers at all —
the runtime’s garbage collector and JSON encoding dominate, same
as any Go HTTP framework.
Project status
Pre-v1.0.0, actively developed. Architecture decisions are
documented as ADRs in docs/adr/ — including one written specifically
to explain why reflection is used at route registration (once, at
startup) without contradicting the build-time codegen thesis.
golangci-lint clean, govulncheck clean, -race clean, fuzz-tested
(2M+ executions on the AST parser with zero panics).
I’d welcome technical feedback, especially on the benchmark
methodology or anywhere the build-time approach might not hold up
under real-world use.