Documentation
¶
Index ¶
- func Generate(config *Config) error
- func NewModelBuilder(config *Config) *modelBuilder
- type Config
- type ConfigGetter
- type ConfigGetterOutput
- type ConfigInput
- type ConfigInputField
- type ConfigInputStruct
- type ConfigOutput
- type ConfigTag
- type ConfigTagInput
- type ConfigTagOutput
- type ConfigTagOutputFormat
- type ConfigTagOutputTransform
- type ConstantFormatType
- type ConstantOutput
- type FieldOutput
- type GetterOutput
- type InputModeType
- type Model
- type NoneOutput
- type OutputModeType
- type PackageModel
- type ReturnOutput
- type ScanError
- type StructModel
- type StructOutput
- type TransformCaseType
- type TypePackageOutput
- type ValueOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewModelBuilder ¶
func NewModelBuilder(config *Config) *modelBuilder
Types ¶
type Config ¶
type Config struct {
Input ConfigInput `yaml:"input"`
Output ConfigOutput `yaml:"output"`
Elements []ConfigTag `yaml:"elements"`
Getters []ConfigGetter `yaml:"getters"`
}
Config represents the main configuration structure for the Constago generator
func LoadConfig ¶
LoadConfig loads and parses the configuration from a YAML file
type ConfigGetter ¶
type ConfigGetter struct {
Name string `yaml:"name"`
Returns []string `yaml:"returns"`
Output ConfigGetterOutput `yaml:"output"`
}
config.getters[i]
type ConfigGetterOutput ¶
type ConfigGetterOutput struct {
Prefix string `yaml:"prefix"`
Suffix string `yaml:"suffix"`
Format ConstantFormatType `yaml:"format"`
}
type ConfigInput ¶
type ConfigInput struct {
Include []string `yaml:"include"`
Exclude []string `yaml:"exclude"`
Dir string `yaml:"dir"`
Struct ConfigInputStruct `yaml:"struct"`
Field ConfigInputField `yaml:"field"`
}
config.input
type ConfigInputField ¶
type ConfigInputStruct ¶
type ConfigTag ¶
type ConfigTag struct {
Name string `yaml:"name"`
Input ConfigTagInput `yaml:"input"`
Output ConfigTagOutput `yaml:"output"`
}
config.tags[i]
type ConfigTagInput ¶
type ConfigTagInput struct {
Mode InputModeType `yaml:"mode"`
TagPriority []string `yaml:"tag_priority"`
}
type ConfigTagOutput ¶
type ConfigTagOutput struct {
Mode OutputModeType `yaml:"mode"`
Format ConfigTagOutputFormat `yaml:"format"`
Transform ConfigTagOutputTransform `yaml:"transform"`
}
type ConfigTagOutputFormat ¶
type ConfigTagOutputFormat struct {
Holder ConstantFormatType `yaml:"holder"`
Struct ConstantFormatType `yaml:"struct"`
Prefix string `yaml:"prefix"`
Suffix string `yaml:"suffix"`
}
type ConfigTagOutputTransform ¶
type ConfigTagOutputTransform struct {
TagValues *bool `yaml:"tag_values"`
ValueCase TransformCaseType `yaml:"value_case"`
ValueSeparator string `yaml:"value_separator"`
}
type ConstantFormatType ¶
type ConstantFormatType string
ConstantFormatType
const ( ConstantFormatCamel ConstantFormatType = "camel" ConstantFormatPascal ConstantFormatType = "pascal" ConstantFormatSnake ConstantFormatType = "snake" ConstantFormatSnakeUpper ConstantFormatType = "snakeUpper" )
type ConstantOutput ¶
type FieldOutput ¶
type GetterOutput ¶
type GetterOutput struct {
Name string
Returns []*ReturnOutput
}
type InputModeType ¶
type InputModeType string
InputModeType
const ( InputModeTypeTagThenField InputModeType = "tagThenField" InputModeTypeField InputModeType = "field" InputModeTypeTag InputModeType = "tag" )
type Model ¶
type Model struct {
// Packages organized by path
Packages map[string]*PackageModel
// Scanning statistics
FilesScanned int
PackagesFound int
StructsFound int
FieldsFound int
// Errors encountered during scanning
Errors []*ScanError
}
type NoneOutput ¶
type OutputModeType ¶
type OutputModeType string
OutputModeType
const ( OutputModeNone OutputModeType = "none" OutputModeStruct OutputModeType = "struct" OutputModeConstant OutputModeType = "constant" )
type PackageModel ¶
type PackageModel struct {
// Package information
Name string
Path string
// Imports to use in the generated code
Imports map[string]*TypePackageOutput
// Structs to generate validators for
Structs []*StructModel
}
type ReturnOutput ¶
type ReturnOutput struct {
Field *FieldOutput
Constant *ConstantOutput
None *NoneOutput
Value *ValueOutput
}
type StructModel ¶
type StructModel struct {
Name string
File string
LineNumber int
// Fields that should have code to generate
Constants []*ConstantOutput
Structs []*StructOutput
Getters []*GetterOutput
}
StructInfo represents a struct that should have code to generate
type StructOutput ¶
type StructOutput struct {
Name string
Package string
Fields []*FieldOutput
}
type TransformCaseType ¶
type TransformCaseType string
TransformCaseType
const ( TransformCaseAsIs TransformCaseType = "asIs" TransformCaseCamel TransformCaseType = "camel" TransformCasePascal TransformCaseType = "pascal" TransformCaseUpper TransformCaseType = "upper" TransformCaseLower TransformCaseType = "lower" )
type TypePackageOutput ¶
type ValueOutput ¶
type ValueOutput struct {
FieldName string
TypeName string
TypePackage *TypePackageOutput
}
Click to show internal directories.
Click to hide internal directories.