generator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package generator produces Go source code for struct mappers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldData

type FieldData struct {
	SourceField   string
	TargetField   string
	Kind          string // "direct", "converter", "nested", "slice"
	ConverterCall string
	NestedCall    string
	SliceCall     string
	HasError      bool
	VarName       string
	NilOrZero     string // "nil" for pointer returns, "Type{}" for value returns
}

FieldData holds data for a single field mapping.

type FileData

type FileData struct {
	PackageName string
	Imports     []ImportEntry
	Functions   []FunctionData
}

FileData holds data for generating a complete file.

type FunctionData

type FunctionData struct {
	Name            string
	SourceType      string
	TargetType      string
	SourceQualified string
	TargetQualified string
	IsPointer       bool
	ReturnsPointer  bool
	HasError        bool
	Fields          []FieldData
}

FunctionData holds data for generating a single function.

type Generator

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

Generator produces mapper code.

func New

func New(reg *registry.Registry, outputPkg, outputPkgPath, outputPath string) *Generator

New creates a new Generator.

func (*Generator) GenerateFile

func (g *Generator) GenerateFile(mappings []*resolver.Mapping, direction string) ([]byte, error)

GenerateFile generates a complete mapper file for the given mappings.

type ImportEntry added in v0.0.9

type ImportEntry struct {
	Path  string
	Alias string // empty if no alias needed
}

ImportEntry represents a single import with an optional alias.

Jump to

Keyboard shortcuts

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