schemaconcat

package
v0.2026331.1553 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func ConcatSchema(fsys fs.FS, dir string, exclude func(name string) bool) (string, []string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL