Documentation
¶
Overview ¶
Package codegen implements `quark gen`: it parses a user's package with go/packages + go/types (not reflection, so the tool can be `go install`ed and driven from //go:generate) and emits, per package, a quark_gen.go that registers typed implementations with the runtime registry in package quark.
F6-1 ships the pipeline and the registration contract only: the emitted scanner/binder are inert stubs (quark.StubScanner / quark.StubBinder) and the runtime hot paths do not yet consult the registry. The typed fast path is F6-2 (scanning) and F6-3 (binding). See ADR-0014.
Index ¶
Constants ¶
const GeneratedFileName = "quark_gen.go"
GeneratedFileName is the file each package's registrations are written to.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate loads the packages matching patterns and writes a quark_gen.go into each package that contains models. It returns the paths written.
func Render ¶
func Render(pm PackageModels) ([]byte, error)
Render produces the gofmt'd contents of a package's quark_gen.go. The file stamps the contract version it was generated against (a literal, not a reference to GenContractVersion, so a stale file keeps its old version and the runtime's version gate can detect it), registers per model a version+hash, a typed scanner, and — for integer-PK models — a typed INSERT binder (other models register the stub binder and bind via reflection).
Types ¶
type ModelDef ¶
type ModelDef struct {
Name string
Fields []quark.ModelField
Hash string
}
ModelDef is a model struct discovered in a package: a struct with at least one exported field carrying a `db` tag.
type PackageModels ¶
PackageModels groups the models found in one package, with the on-disk directory where its quark_gen.go should be written.
func Load ¶
func Load(patterns ...string) ([]PackageModels, error)
Load type-checks the packages matching patterns and returns those that contain at least one model. Patterns use go/packages syntax (e.g. "./...", an import path, or a directory).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sample holds a representative model used by the codegen tests: the conformance test loads it via go/packages (AST) and via reflection, and the golden test regenerates its quark_gen.go and compares.
|
Package sample holds a representative model used by the codegen tests: the conformance test loads it via go/packages (AST) and via reflection, and the golden test regenerates its quark_gen.go and compares. |