codegen

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package codegen emits reflection-free apply functions from intermediate minitoml.Document keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(packageName string, specs []Spec) ([]byte, error)

Generate emits Go source with Apply* functions that map minitoml.Document keys onto structs. Key paths are resolved at generation time; generated code does not use reflection or tag parsing.

Types

type Field

type Field struct {
	// GoName is the exported Go field name.
	GoName string
	// Key is the relative TOML/intermediate key segment under the parent prefix.
	Key string
	// Kind is the field type.
	Kind FieldKind
	// Nested holds child fields when Kind is FieldStruct.
	Nested []Field
	// Default is an optional default used when the key is absent (string form).
	Default string
	// Opt is an optional CLI name override ("long" or "long,short").
	Opt string
	// Env is an optional exact environment variable override, or "-" to disable it.
	Env string
	// Help is optional CLI/scaffold help text.
	Help string
	// Arg is a subcommand-only positional role: required, optional, or *.
	Arg string
}

Field describes one struct field for intermediate-form apply generation.

type FieldKind

type FieldKind int

FieldKind is the Go field kind supported by the generator.

const (
	// FieldString is a string field.
	FieldString FieldKind = iota
	// FieldBool is a bool field.
	FieldBool
	// FieldInt is an int field.
	FieldInt
	// FieldStringSlice is a []string field.
	FieldStringSlice
	// FieldStruct is a nested struct field.
	FieldStruct
)

type Spec

type Spec struct {
	// TypeName is the Go struct type name (e.g. WebServiceConfig).
	TypeName string
	// Prefix is the Bind prefix / top-level TOML table (e.g. webservice).
	Prefix string
	// Fields are the struct fields.
	Fields []Field
}

Spec describes one Bind-style config struct and its prefix table name.

func WebServiceFixtureSpec

func WebServiceFixtureSpec() Spec

WebServiceFixtureSpec returns the representative Bind-style fixture used by tests and committed gen code.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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