Documentation
¶
Overview ¶
THE single schema-concatenation contract (R3).
Both the runtime (charly core (cue_schema.go) `sharedCueSchema`) and the dev-time code generator (schemagen) need to concatenate every schema/*.cue file into ONE package-less compilation unit. They used to carry two byte-identical-by-comment copies of the same loop; this is the ONE copy they both call, so the compiled schema (what the runtime validates against) and the generated Go types (`schemaparams`) can never drift.
The schema files are ALSO a real CUE package in the `github.com/opencharly/spec` module (`cue.mod/module.cue`; `package schema`, loaded by `cue eval ./schema`). The text splice and the package are one schema in two forms during the cutover: the splice stays the runtime path until charly imports the package, so ConcatSchema normalizes a file's package clause away and the joined body it returns is unchanged, byte for byte, from the pre-package one.
Leaf package (no deps beyond stdlib `io/fs`) so the dev-time generator can call it WITHOUT importing the spec package it regenerates. That is why the clause is stripped textually rather than by parsing: parsing would make this leaf take cuelang.org/go for what is a line deletion.
STANDALONE: depends only on the stdlib `io/fs` abstraction, so the runtime passes its `//go:embed` FS and the generator passes `os.DirFS(schemaDir)`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcatSchema ¶
ConcatSchema reads every `*.cue` file in fsys under dir (skipping any for which exclude reports true — pass nil to include all), sorts the names for a deterministic result, and joins the file bodies with a trailing newline. It returns the joined body (WITHOUT any package clause) and the sorted list of files included. A file's leading `package <name>` declaration — the schema is a CUE package in the spec module — is removed, together with the single blank line that conventionally separates it from the first declaration; every other byte is preserved.
Types ¶
This section is empty.