Documentation
¶
Overview ¶
Package models turns the declarations of the Go model into the data its templates render.
Index ¶
- func Templates() render.Set
- type AdditionalView
- type CheckView
- type ChoiceView
- type ConstView
- type DeclView
- type ErrorView
- type FieldView
- type Generator
- type GetterView
- type LiteralView
- type LoopView
- type MaskFieldView
- type MaskView
- type MethodView
- type PartView
- type PatternView
- type ShapeView
- type UnionView
- type ValidateView
- type VariantCheckView
- type VariantView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdditionalView ¶
type AdditionalView struct {
Receiver string
Field string
Map string
Value string
Known []string
Runtime string
Form string
}
AdditionalView is what the methods of a struct with additional properties need. Field is the field that holds them and Map its type, Value the type of its values, Known the quoted JSON names of the other fields and Runtime the name the runtime package is imported under. Form, the form type, adds UnmarshalForm.
type CheckView ¶
type CheckView struct {
Errs string
Path string
Value string
Deref string
Guard string
IsRequired bool
NullCheck string
Calls []string
Items *LoopView
Values *LoopView
}
CheckView checks one value. Every text is a Go expression: Calls return an error that is added to Errs under Path, Deref is Value behind its pointer. Guard is what the calls run under, NullCheck the call that rejects a null Nullable.
type ChoiceView ¶
type ChoiceView struct {
Func string
Members []VariantCheckView
}
ChoiceView is the call that checks how many of Members pass: AnyValid or OneValid.
type DeclView ¶
type DeclView struct {
Doc string
Name string
IsStruct bool
IsUnion bool
IsEnum bool
IsAlias bool
IsDefined bool
Target string
Fields []FieldView
Values []ConstView
ValuesFunc string
Additional *AdditionalView
Getters []GetterView
Union *UnionView
Validate *ValidateView
Error *ErrorView
Mask *MaskView
}
DeclView is one declaration. Target is the aliased or underlying type, or the base of an enum.
type ErrorView ¶
type ErrorView struct {
Receiver string
Runtime string
Path string
PathLiteral string
Fallback string
HasConstructor bool
}
ErrorView is what the Error method and the constructor of an error type need.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator builds the template data of every models part.
type GetterView ¶
type GetterView struct {
Doc string
Receiver string
Name string
Type string
Default string
Unset string
Value string
}
GetterView is a method that returns Value, or Default when Unset holds.
type LiteralView ¶
type LiteralView struct {
Type string
Runtime string
Receiver string
IsAnyOf bool
IsLiteral bool
Discriminator string
Variants []VariantView
Also []LiteralView
}
LiteralView is a runtime.Union literal; Type is empty in Also, Discriminator and Shared quoted.
type LoopView ¶
type LoopView struct {
Index string
Item string
Range string
Map string
Key *CheckView
Check *CheckView
}
LoopView checks each item of a slice, or each key and value of a map in key order. Range is what the loop ranges over, Index and Item its variables, Map the map; Key or Check is nil when unused.
type MaskFieldView ¶
MaskFieldView sets Target to Value, Go expressions, when Guard holds or is empty.
type MaskView ¶
type MaskView struct {
Receiver string
Mask string
Slog string
Fields []MaskFieldView
}
MaskView is what Masked and LogValue need. Mask and Slog are the names of their imports.
type MethodView ¶
type MethodView struct {
Validation string
Counts []string
Discriminator string
Checks []CheckView
VariantChecks []CheckView
Choices []ChoiceView
}
MethodView is the body of one Validate method; all but Validation and Checks are union checks.
type PartView ¶
type PartView struct {
Patterns []PatternView
Decls []DeclView
}
PartView is the data of one part: the patterns its checks use and its declarations in model order.
type PatternView ¶
PatternView is one package-level regular expression.
type UnionView ¶
type UnionView struct {
Receiver string
Runtime string
JSON string
Form string
Which string
Marshal string
IsAnyOf bool
IsGrouped bool
IsDescribed bool
IsText bool
HasUnion bool
Variants []VariantView
Args []string
Literal LiteralView
}
UnionView is what a union's variant fields and methods need. Runtime and JSON are the names the packages are imported under, JSON only when shared fields are decoded. IsText adds MarshalText and UnmarshalText; Form, the form type, UnmarshalForm. Which is what decoding sets in doc lines, Marshal the runtime func that writes the variants. IsDescribed uses Args instead.
type ValidateView ¶
type ValidateView struct {
Receiver string
Validation string
Enum []string
Request MethodView
Response *MethodView
}
ValidateView is what the Validate methods of a declaration need. Enum lists the constants an enum takes; Response is set when ValidateResponse checks something else than Validate.
type VariantCheckView ¶
VariantCheckView is one union member; Check is nil when it checks nothing.
type VariantView ¶
type VariantView struct {
Name string
Type string
Kinds []string
Values []string
IsDefault bool
IsAbsent bool
Required []string
Known []string
HasKnown bool
IsClosed bool
Shapes []ShapeView
}
VariantView is one variant field and what decoding needs to know of it. Kinds are runtime.Kind constant names; Values, Required and Known are quoted. HasKnown writes Known even when empty.