Documentation ¶
Index ¶
- func ExtendStruct(val any) *treeBuilderImpl
- func MergeStructs(strcts ...interface{}) (a any, err error)
- func NewBuilder() *treeBuilderImpl
- type Builder
- type DynamicStructModifier
- type DynamicStructModifierImpl
- func (dm *DynamicStructModifierImpl) Apply(field string, value any) error
- func (dm *DynamicStructModifierImpl) Get(field string) (any, error)
- func (dm *DynamicStructModifierImpl) GetFields() FieldData
- func (dm *DynamicStructModifierImpl) Instance() any
- func (dm *DynamicStructModifierImpl) New() any
- func (dm *DynamicStructModifierImpl) Set(field string, value any) error
- func (dm *DynamicStructModifierImpl) String() string
- func (dm *DynamicStructModifierImpl) Update()
- type FieldData
- type FieldModifier
- type FieldNode
- type GeneratedStruct
- type GeneratedStructImpl
- func (gs *GeneratedStructImpl) Generate()
- func (gs *GeneratedStructImpl) GenerateAndUpdate()
- func (gs *GeneratedStructImpl) GetFieldGenerationConfig(field string) *generator.GenerationConfig
- func (gs *GeneratedStructImpl) GetFieldGenerator(field string) *generator.Generator
- func (gs *GeneratedStructImpl) SetFieldDefaultGenerationFunction(field string, generationFunction generator.GenerationFunction)
- func (gs *GeneratedStructImpl) SetFieldGenerationConfig(field string, generationConfig *generator.GenerationConfig) error
- func (gs *GeneratedStructImpl) SetFieldGenerator(field string, generator *generator.Generator)
- type GenerationFields
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtendStruct ¶
func ExtendStruct(val any) *treeBuilderImpl
func MergeStructs ¶
MergeStructs merges two structs
func NewBuilder ¶
func NewBuilder() *treeBuilderImpl
Types ¶
type Builder ¶
type Builder interface { // AddField adds a field to the struct. AddField(name string, value interface{}, tag string) Builder // AddEmbeddedFields adds an embedded field to the struct. AddEmbeddedField(value interface{}, tag string) Builder // Build returns a DynamicStructModifier instance. Build() DynamicStructModifier // GetField returns a builder instance of the subfield of the struct that is currently being built. GetField(name string) Builder // GetFieldCopy returns a copy of a builder instance of the subfield of the struct that is currently being built. // // Deprecated: this method will be removed use NewBuilderFromField instead. GetFieldCopy(name string) Builder // GetNewBuilderFromField returns a new builder instance where the subfield of the struct "field" is the root of the struct. NewBuilderFromField(field string) Builder // RemoveField removes a field from the struct. If the field is a subfield of a nil struct it will not be removed. RemoveField(field string) Builder }
type DynamicStructModifier ¶
type DynamicStructModifier interface { // Instance returns a copy of the struct Instance() any // New returns a pointer to the struct New() any // Get gets the value of the struct field `field` and returns an error if the field is not found Get(field string) (any, error) // Set sets the value of the struct field `field` and returns an error if the field is not found. // // The program will panic if the type of value does not match the type of the struct field `field`. Set(field string, value any) error // GetFields returns a map containing all fields within a struct GetFields() FieldData // Update updates the struct's underlying tree to represent that of the strct's value Update() // Apply is a combination of Set and Update. Update is not called if Apply fails. Apply(field string, value any) error }
type DynamicStructModifierImpl ¶
type DynamicStructModifierImpl struct {
// contains filtered or unexported fields
}
func (*DynamicStructModifierImpl) Apply ¶ added in v1.1.0
func (dm *DynamicStructModifierImpl) Apply(field string, value any) error
func (*DynamicStructModifierImpl) Get ¶
func (dm *DynamicStructModifierImpl) Get(field string) (any, error)
func (*DynamicStructModifierImpl) GetFields ¶ added in v0.1.1
func (dm *DynamicStructModifierImpl) GetFields() FieldData
func (*DynamicStructModifierImpl) Instance ¶
func (dm *DynamicStructModifierImpl) Instance() any
func (*DynamicStructModifierImpl) New ¶
func (dm *DynamicStructModifierImpl) New() any
func (*DynamicStructModifierImpl) Set ¶
func (dm *DynamicStructModifierImpl) Set(field string, value any) error
func (*DynamicStructModifierImpl) String ¶
func (dm *DynamicStructModifierImpl) String() string
func (*DynamicStructModifierImpl) Update ¶ added in v1.1.0
func (dm *DynamicStructModifierImpl) Update()
type FieldModifier ¶
type FieldModifier func(*structField)
type GeneratedStruct ¶
type GeneratedStruct interface { DynamicStructModifier // Generate generates fields for the struct Generate() // GenerateAndUpdate Generates fields and updates the root tree for the underlying struct. Allowing // new generated fields to be accessed and modified by Set and Get methods. GenerateAndUpdate() // GetFieldGenerationConfig gets the generation config for field within the struct. GetFieldGenerationConfig(field string) *generator.GenerationConfig // SetFieldGenerationConfig sets the generation config for field within the struct. It returns // an error if the field does not exist or if the field cannot be generated. // Fields that can be generated are struct fields of the most basic type i.e a struct fields // that are structs cannot be generated, however it's fields can be. // // Fields types that cannot be generated: structs, func, chan, any (will default to a nil value being generated). // // Note: Pointers to structs can be generated. SetFieldGenerationConfig(field string, generationConfig *generator.GenerationConfig) error }
type GeneratedStructImpl ¶
type GeneratedStructImpl struct { *DynamicStructModifierImpl // contains filtered or unexported fields }
func NewGeneratedStruct ¶
func NewGeneratedStruct(val any) *GeneratedStructImpl
func NewGeneratedStructWithConfig ¶
func NewGeneratedStructWithConfig(val any, gen *generator.Generator) *GeneratedStructImpl
func (*GeneratedStructImpl) Generate ¶
func (gs *GeneratedStructImpl) Generate()
func (*GeneratedStructImpl) GenerateAndUpdate ¶ added in v1.1.1
func (gs *GeneratedStructImpl) GenerateAndUpdate()
func (*GeneratedStructImpl) GetFieldGenerationConfig ¶
func (gs *GeneratedStructImpl) GetFieldGenerationConfig(field string) *generator.GenerationConfig
func (*GeneratedStructImpl) GetFieldGenerator ¶ added in v0.1.2
func (gs *GeneratedStructImpl) GetFieldGenerator(field string) *generator.Generator
func (*GeneratedStructImpl) SetFieldDefaultGenerationFunction ¶ added in v0.1.2
func (gs *GeneratedStructImpl) SetFieldDefaultGenerationFunction(field string, generationFunction generator.GenerationFunction)
func (*GeneratedStructImpl) SetFieldGenerationConfig ¶
func (gs *GeneratedStructImpl) SetFieldGenerationConfig(field string, generationConfig *generator.GenerationConfig) error
func (*GeneratedStructImpl) SetFieldGenerator ¶ added in v0.1.2
func (gs *GeneratedStructImpl) SetFieldGenerator(field string, generator *generator.Generator)
type GenerationFields ¶
type GenerationFields map[string]*generator.GenerationUnit
type Node ¶
type Node[T any] struct { // contains filtered or unexported fields }
func (*Node[T]) DeleteNode ¶
func (*Node[T]) HasChildren ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.