codegen

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Overview

Package codegen renders a resolved plan into gofmt-compatible Go source.

Output is deterministic: the same input always produces byte-identical source. Imports and local variable names are derived from the graph, with numeric suffixes assigned in a stable order to resolve conflicts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File accumulates the generated functions for one package.

func NewFile

func NewFile(pkg *packages.Package, opts Options, header string) *File

NewFile returns an empty generated file for pkg under a leading comment.

func (*File) AddGraph

func (f *File) AddGraph(g *model.Graph, plan *resolve.Plan) error

AddGraph renders one graph into the file.

func (*File) Bytes

func (f *File) Bytes() ([]byte, error)

Bytes formats and returns the generated file.

func (*File) Empty

func (f *File) Empty() bool

Empty reports whether no functions were generated.

type Options

type Options struct {
	// LoomPkg is the loom package, used for loom.NewLifecycle.
	LoomPkg *types.Package
	// LifecyclePtr is *loom.Lifecycle.
	LifecyclePtr types.Type
	// Cleanup is loom.Cleanup.
	Cleanup types.Type
	// Context is context.Context.
	Context types.Type
	// ErrorsPkg is the standard library errors package, used for errors.Join.
	ErrorsPkg *types.Package
}

Options carries the framework types codegen needs to reference.

Jump to

Keyboard shortcuts

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