Documentation
¶
Overview ¶
typefactory/typefactory.go
internal/typefactory/hooks.go
Index ¶
- func StringToBoolHook(from reflect.Kind, to reflect.Kind, data interface{}) (interface{}, error)
- func StringToFloatHook(from reflect.Kind, to reflect.Kind, data interface{}) (interface{}, error)
- func StringToIntHook(from reflect.Kind, to reflect.Kind, data interface{}) (interface{}, error)
- func StringToIntHookFunc() mapstructure.DecodeHookFunc
- func StringToMapStringHookFunc() mapstructure.DecodeHookFunc
- func StringToSliceHook(from reflect.Kind, to reflect.Kind, data interface{}) (interface{}, error)
- func StringToSliceHookFunc() mapstructure.DecodeHookFunc
- type TypeFactory
- type TypeRequest
- type TypeResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringToBoolHook ¶
StringToBoolHook converts string values to booleans during decoding.
func StringToFloatHook ¶
func StringToFloatHook( from reflect.Kind, to reflect.Kind, data interface{}, ) (interface{}, error)
StringToFloatHook converts string values to floats during decoding.
func StringToIntHook ¶
StringToIntHook converts string values to integers during decoding.
func StringToIntHookFunc ¶
func StringToIntHookFunc() mapstructure.DecodeHookFunc
StringToIntHookFunc converts a string to an int, defaulting to 0 if parsing fails
func StringToMapStringHookFunc ¶
func StringToMapStringHookFunc() mapstructure.DecodeHookFunc
stringToMapStringHookFunc converts a string to a map[string]string by returning an empty map
func StringToSliceHook ¶
func StringToSliceHook( from reflect.Kind, to reflect.Kind, data interface{}, ) (interface{}, error)
StringToSliceHook converts comma-separated strings to slices of strings.
func StringToSliceHookFunc ¶
func StringToSliceHookFunc() mapstructure.DecodeHookFunc
stringToSliceHookFunc converts a single string to a []string
Types ¶
type TypeFactory ¶
type TypeFactory struct {
// contains filtered or unexported fields
}
TypeFactory is responsible for creating instances of types based on type names.
func NewTypeFactory ¶
func NewTypeFactory() *TypeFactory
NewTypeFactory initializes a new TypeFactory.
func (*TypeFactory) CreateInstance ¶
func (tf *TypeFactory) CreateInstance(request TypeRequest) (*TypeResponse, error)
CreateInstance creates an instance of the requested type and validates it.
func (*TypeFactory) RegisterType ¶
func (tf *TypeFactory) RegisterType(typeName string, typ reflect.Type)
RegisterType registers a new type with the factory.
type TypeRequest ¶
TypeRequest represents a request to create an instance of a type.
type TypeResponse ¶
TypeResponse represents the response from TypeFactory.