runner

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package runner executes tygor code generation by building and running a modified version of the user's package.

It uses Go's -overlay flag to replace the user's main() with a runner that calls the export function and generates output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(opts Options) (output []byte, err error)

Exec builds and runs the generator.

For package main: uses overlay to replace main() with runner main(). For other packages: creates a temp module that imports the target package.

Types

type Options

type Options struct {
	// Export is the function to call.
	Export discover.Export

	// OutDir is the output directory for generated files.
	OutDir string

	// Flavor is the optional flavor flag (e.g., "zod").
	// Only used when Export.Type is ExportTypeApp.
	Flavor string

	// Discovery enables discovery.json generation.
	// Only used when Export.Type is ExportTypeApp.
	Discovery bool

	// ConfigFunc is the optional config function name.
	// Only used when Export.Type is ExportTypeApp.
	ConfigFunc string

	// NoConfig disables the config function even if one exists.
	NoConfig bool

	// PkgDir is the directory containing the package.
	PkgDir string

	// PkgPath is the import path of the package (e.g., "github.com/foo/bar").
	// Required for non-main packages.
	PkgPath string

	// ModulePath is the module path (e.g., "github.com/foo").
	// Required for non-main packages.
	ModulePath string

	// ModuleDir is the directory containing the module's go.mod.
	// Required for non-main packages.
	ModuleDir string

	// CheckMode runs validation only, outputs JSON stats instead of generating files.
	CheckMode bool
}

Options configures the runner.

Jump to

Keyboard shortcuts

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