types: generate TypeScript from engine structs with tygo

tygo is pinned via go.mod's tool directive (Go 1.24+): the tool's
version is locked like any dependency and runs as 'go tool tygo', no
global install. 'go generate ./...' regenerates web/src/types/engine.ts
from Config/Result and their json tags; the generated file is committed
so the frontend builds without Go installed. The go:generate directive
anchors in a root generate.go because generate runs commands from the
declaring file's directory and tygo reads tygo.yaml from the cwd.
go.mod's ignore directive (Go 1.25+) keeps ./... from crawling into
web/node_modules, where some npm packages ship stray .go files.
This commit is contained in:
Justin Visser 2026-06-10 12:58:13 +02:00
parent f58f33c3fd
commit 9bae4a9ca0
5 changed files with 847 additions and 0 deletions

19
go.mod
View file

@ -1,3 +1,22 @@
module github.com/JustinZeus/spreadlab
go 1.26.3
// Keep Go tooling out of the frontend's dependency tree; some npm packages
// ship stray .go files that ./... would otherwise pick up.
ignore ./web/node_modules
tool github.com/gzuidhof/tygo
require (
github.com/fatih/structtag v1.2.0 // indirect
github.com/gzuidhof/tygo v0.2.21 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/cobra v1.3.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/tools v0.1.9 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)