build

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package build flattens parsed specs into fully-resolved view models. It is the only codegen stage that inspects the spec model; every naming and type decision funnels through here (via the naming package) so templates stay decision-free.

Presence rules: required keys become value fields, optional keys become pointers (or nil-able slices/maps) tagged omitempty. Constraints (rangelist, range, format, repetition, subtypes) become statements in the generated Validate method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(s *spec.Spec, pkg string, kind Kind, shared *SharedTypes, usedConsts map[string]bool) (*view.File, error)

File builds the view model for one spec.

Types

type Kind

type Kind int

Kind selects the wire-identifier method a spec's main struct carries.

const (
	KindCommand     Kind = iota // RequestType()
	KindProfile                 // PayloadType()
	KindDeclaration             // DeclarationType()
	KindPlain                   // no identifier method
)

type SharedTypes

type SharedTypes struct {
	// contains filtered or unexported fields
}

SharedTypes tracks every named nested struct emitted in one package, keyed by name with a shape signature. It serves two purposes: subkeytype reuse across specs (first definition wins, later references reuse), and shape-aware dedup — identical (name, shape) pairs collapse to one type, while a name collision with a different shape gets a numeric suffix.

func NewSharedTypes

func NewSharedTypes() *SharedTypes

NewSharedTypes returns an empty per-package shared-type registry.

Jump to

Keyboard shortcuts

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