Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 GenerateDirectory ¶
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 ¶
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.