gen

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidOpsIntf = map[string]struct{}{
	"structcopygen": {},
}

ValidOpsIntf is a set of valid conversion option keys for interface-level conversion.

View Source
var ValidOpsMethod = map[string]struct{}{
	"skip_field":   {},
	"match_field":  {},
	"match_method": {},
	"conv":         {},
	"struct_conv":  {},
}

ValidOpsMethod is a set of valid conversion option keys for method-level conversion.

Functions

This section is empty.

Types

type Generator

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

Generator instance.

func NewGenerator

func NewGenerator(pkg *packages.Package, fset *token.FileSet, file *ast.File, opts ...GeneratorOption) (*Generator, error)

NewGenerator returns new Generator instance.

func (*Generator) CollectOptions

func (g *Generator) CollectOptions(notations []*ast.Comment, validOps map[string]struct{}) (*structcopy.InputOption, error)

func (*Generator) Generate

func (g *Generator) Generate(outPath string, output, dryRun bool) ([]byte, error)

Generate generates the code into a file with the given path. It returns the generated code as a byte slice.

type GeneratorOption

type GeneratorOption func(g *Generator)

GeneratorOption is option for Generator.

func WithDryRun

func WithDryRun(dryRun bool) GeneratorOption

WithDryRun sets output path.

func WithInputPath

func WithInputPath(input string) GeneratorOption

WithInputPath sets input path.

func WithLogEnabled

func WithLogEnabled(logs bool) GeneratorOption

WithLogEnabled sets output path.

func WithLogPath

func WithLogPath(log string) GeneratorOption

WithLogPath sets output path.

func WithLogger

func WithLogger(logger *slog.Logger) GeneratorOption

WithLogger sets logger.

func WithOutputPath

func WithOutputPath(output string) GeneratorOption

WithOutputPath sets output path.

func WithPrints

func WithPrints(prints bool) GeneratorOption

WithPrints sets output path.

Jump to

Keyboard shortcuts

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