I kept shipping features where the frontend accepted data the backend rejected. Validation rules lived in two places (Go struct tags and TypeScript Zod schemas), and they'd drift.
I built goldenthread to solve this. It's a build-time compiler that generates TypeScript Zod schemas from Go struct tags. Write validation once, use it everywhere.
Example:
// Go backend
type User struct {
Username string `json:"username" gt:"required,len:3..20"`
Email string `json:"email" gt:"email"`
Age int `json:"age" gt:"min:13,max:130"`
}
Run `goldenthread generate ./models` and you get: // TypeScript (auto-generated)
export const UserSchema = z.object({
username: z.string().min(3).max(20),
email: z.string().email(),
age: z.number().int().min(13).max(130)
})
export type User = z.infer<typeof UserSchema>
The compiler uses go/packages and go/types for accurate type resolution. It handles nested objects, enums, maps, embedded structs, and 37+ validation rules.The best feature: drift detection. Run `goldenthread check` in CI - it computes SHA-256 hashes of your schemas and fails the build if generated TypeScript doesn't match Go source. No more "frontend works locally but breaks in production because someone changed the backend struct."
Before releasing v0.1.0, I ran continuous fuzzing (10 targets, hourly in GitHub Actions). It found two bugs my test suite missed:
1. UTF-8 corruption: Japanese field names with empty JSON tags triggered byte-slicing bugs in camelCase conversion. Took 444,553 executions to discover.
2. Regex escaping: Patterns with newline characters produced broken JavaScript output. Found in 180 executions.
Both required specific intersections of conditions that manual testing wouldn't cover. I wrote up the full fuzzing setup here: https://blackwell-systems.github.io/blog/posts/continuous-fu...The tool is production-ready:
Zero runtime dependencies (generated code only imports Zod) Generates readable TypeScript (looks hand-written) Complete Go type support (primitives, arrays, maps, nested objects) Works with any Go project structure MIT OR Apache 2.0 dual licensed
I built this because I was tired of frontend/backend validation bugs in my day job (hospitality platform with booking/payment APIs). We use it internally now.
Real-world example in the repo: 9-schema e-commerce system with Customer records (E.164 phone validation), Product SKUs (regex patterns), and Order workflows (nested objects + array constraints).
GitHub: https://github.com/blackwell-systems/goldenthread Docs: https://github.com/blackwell-systems/goldenthread/blob/main/... Tag syntax: https://github.com/blackwell-systems/goldenthread/blob/main/...
Would love feedback
Thanks for looking!