codegen

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package codegen writes the binding and the validation of each handler input as plain Go.

The generator reads the struct tags one time, at generation time. No generated file imports reflect, and no request path uses it. See the SDD, S5, and design rule 2.

A fault names a file, a line and a column in the code that the person wrote. It never points into a template or into a generated file. See DX-6.

Index

Constants

View Source
const GeneratedFile = "zz_generated.go"

GeneratedFile is the name that the generator writes in each package.

Variables

This section is empty.

Functions

func Check

func Check(dir string) error

Check reports a generated file that is not current. It writes nothing.

func Generate

func Generate(dir string) ([]string, error)

Generate writes the generated file for each package under dir that holds a handler. It returns the paths that it wrote, in order. A package with no handler gets no file.

Types

type Fault

type Fault struct {
	// File is the file that holds the fault.
	File string `json:"file"`
	// Line is the line of the struct field.
	Line int `json:"line"`
	// Column is the column of the struct field.
	Column int `json:"column"`
	// Message states the fault.
	Message string `json:"message"`
	// Repair states what to do. It is one sentence.
	Repair string `json:"repair"`
}

Fault is one generation fault. It names a file, a line and a column in code that the person wrote, and it states the repair in one sentence. It never points into a template, into a generated file or into Avero. See DX-6 and DX-7.

func (*Fault) Error

func (f *Fault) Error() string

Error prints the position, the message and the repair.

type Faults

type Faults struct {
	Faults []*Fault `json:"faults"`
}

Faults holds every fault of one run. The generator reports every fault, not only the first.

func (*Faults) Error

func (l *Faults) Error() string

Error returns a count and one entry for each fault.

func (*Faults) Unwrap

func (l *Faults) Unwrap() []error

Unwrap returns each fault so that errors.As reaches a single one.

type StaleFault

type StaleFault struct {
	// Path is the generated file.
	Path string `json:"path"`
	// Reason states what is wrong.
	Reason string `json:"reason"`
}

StaleFault reports a generated file that a run of the generator would change.

func (*StaleFault) Error

func (f *StaleFault) Error() string

Error states the fault and the repair.

Directories

Path Synopsis
Package client holds the HTTP client generator and the runtime that its output calls, S13.
Package client holds the HTTP client generator and the runtime that its output calls, S13.
internal/example
Package example holds the client that the tests of the generator drive.
Package example holds the client that the tests of the generator drive.
internal
example
Package example is the fixture of the generator.
Package example is the fixture of the generator.

Jump to

Keyboard shortcuts

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