Documentation
¶
Index ¶
- func CanExtend(val any) bool
- func GetPointerToSliceType(sliceType reflect.Type) any
- func MergeStructs(strcts ...interface{}) (a any, err error)
- func Print(strct any) string
- type Builder
- type DynamicStructModifier
- type DynamicStructModifierImpl
- type Field
- type FieldMap
- type FieldModifier
- type GeneratedStruct
- type GeneratedStructImpl
- type GenerationFields
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPointerToSliceType ¶
func MergeStructs ¶
MergeStructs merges two structs
Types ¶
type Builder ¶
type Builder interface {
// AddField adds a field to the struct.
AddField(name string, 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.
GetFieldCopy(field string) Builder
// RemoveField removes a field from the struct.
RemoveField(name string) Builder
}
func ExtendStruct ¶
func NewBuilder ¶
func NewBuilder() 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
}
type DynamicStructModifierImpl ¶
type DynamicStructModifierImpl struct {
// contains filtered or unexported fields
}
func (*DynamicStructModifierImpl) Get ¶
func (dm *DynamicStructModifierImpl) Get(field string) (any, error)
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
type Field ¶
type Field struct {
Name string
Tag reflect.StructTag
Value reflect.Value
Type reflect.Type
StructIndex int
SubFields int
// contains filtered or unexported fields
}
func (Field) GetFieldFQName ¶
func (Field) GetFieldName ¶
type FieldModifier ¶
type FieldModifier func(*Field)
type GeneratedStruct ¶
type GeneratedStruct interface {
DynamicStructModifier
// Generate generates fields for the struct
Generate()
// 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, config *generator.GenerationConfig) *GeneratedStructImpl
func (*GeneratedStructImpl) Generate ¶
func (gs *GeneratedStructImpl) Generate()
func (*GeneratedStructImpl) GetFieldGenerationConfig ¶
func (gs *GeneratedStructImpl) GetFieldGenerationConfig(field string) *generator.GenerationConfig
func (*GeneratedStructImpl) SetFieldGenerationConfig ¶
func (gs *GeneratedStructImpl) SetFieldGenerationConfig(field string, generationConfig *generator.GenerationConfig) error
type GenerationFields ¶
type GenerationFields map[string]*generator.GenerationUnit
type Node ¶
type Node[T any] struct { // contains filtered or unexported fields }
Struct will be represented using a Tree
func (*Node[T]) DeleteNode ¶
func (*Node[T]) HasChildren ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.