mirror of
https://github.com/larksuite/cli.git
synced 2026-07-07 00:55:53 +08:00
Migrate the startup command-tree build path to read compile-time static
Go structs (metastatic.Registry, behind -tags larkmeta) instead of parsing
the 1.9MB meta_data.json into map[string]interface{} (~170K heap objects)
on every invocation.
- typed.go: typed baseline + remote-overlay layer. Reads static data under
-tags larkmeta (zero parse / zero alloc); falls back to parsing the
embedded meta_data.json once for builds without the tag (dev/test). A lazy
typed->map shim (ServiceToMap/MethodToMap) keeps execution-path consumers
working unchanged.
- service.go: registration chain and NewCmdServiceMethod read typed structs
directly; map wrappers convert via MapToService/MapToMethod for existing
tests; method RunE materializes opts.Spec/opts.Method lazily, never at
startup.
- loader.go/remote.go: baseline and cached remote overlay decode into the
typed shape; runtime refresh preserved.
- build pipeline: Makefile, goreleaser and pkg-pr-new run the generator and
build with -tags larkmeta so shipped binaries carry the static data.
Reading the full static registry is 0 B/op, 0 allocs/op; the built command
tree is byte-identical to the JSON-parsed tree (verified via a canonical
tree dump in both modes).