Documentation ¶
Overview ¶
Package ref for struct instance reflector.
Index ¶
Constants ¶
View Source
const ( TagDescription = "desc" TagExec = "exec" TagIgnore = "ignore" TagLabel = "label" TagMock = "mock" TagName = "json" TagValidate = "validate" )
Variables ¶
View Source
var ( RegexMatchAllowEmptyField = regexp.MustCompile(`omitempty\s*,\s*`) RegexMatchExportedField = regexp.MustCompile(`^[A-Z]`) RegexMatchRequiredField = regexp.MustCompile(`required`) RegexRemoveOmitEmpty = regexp.MustCompile(`\s*,\s*omitempty`) RegexRemoveRequires = []*regexp.Regexp{ regexp.MustCompile(`\s*,\s*required`), regexp.MustCompile(`required\s*,\s*`), } )
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { Fields []*Field Pkg string Struct string // contains filtered or unexported fields }
Builder is a component that used to parse the instance to field lists.
type Field ¶
type Field struct {
Name, Condition string
Label, Description string
Mock any
AllowEmpty bool
Ignored, IsArray, IsRequired, IsStruct bool
TrueType string
Child *Builder
OriginName string
OriginType reflect.Type
// contains filtered or unexported fields
}
Field is a component that represents a field of a struct instance.
type RegisterManager ¶
type RegisterManager interface { // Add // adds a new instance to the register manager. // // ref.Registry.Add("app/logics/user/login.Request", login.Request{}) Add(name string, instance any) RegisterManager // Get // gets a struct instance by name. // // obj, has := ref.Registry.Get("app/logics/user/login.Request") Get(name string) (instance any, has bool) }
RegisterManager is a register manager that can register and get struct instances.
var Registry RegisterManager
Registry is a singleton instance of register manager.
Click to show internal directories.
Click to hide internal directories.