modelschema

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoGoFilesFound indicates no .go files were found in the directory.
	ErrNoGoFilesFound = errors.New("no .go files found in directory")
	// ErrNoPackagesFound indicates no packages were found during parsing.
	ErrNoPackagesFound = errors.New("no packages found")
	// ErrMultiplePackages indicates multiple packages were found when expecting one.
	ErrMultiplePackages = errors.New("expected 1 package, found multiple")
	// ErrFileNotFoundInPackage indicates the target file was not found in the package.
	ErrFileNotFoundInPackage = errors.New("file not found in package")
)

Functions

func Command

func Command() *cobra.Command

Command returns the generate-model-schema cobra command.

func GenerateDirectory

func GenerateDirectory(inputDir, outputDir, packageName string) error

GenerateDirectory processes all model files in a directory and generates corresponding schemas. The package is loaded and type-checked once and every file's schemas are extracted from that single load — loading per file would type-check the whole package again for each of its files, making generation time quadratic in package size. Test files and files excluded by build constraints are not part of the loaded package and are skipped.

func GenerateFile

func GenerateFile(inputFile, outputFile, packageName string) error

GenerateFile processes a single model file and generates its schema file.

Types

type ModelField

type ModelField struct {
	GoName     string
	ColumnName string
	MethodName string
	Label      string
	Scanonly   bool
}

ModelField represents a single field in a model struct with its Go and database metadata.

type ModelSchemaInfo

type ModelSchemaInfo struct {
	PackageName    string
	ModelName      string
	SchemaTypeName string
	VarName        string
	TableName      string
	AliasName      string
	Fields         []ModelField
}

ModelSchemaInfo contains complete metadata for generating a model schema helper.

Jump to

Keyboard shortcuts

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