Documentation
¶
Index ¶
- func DefaultBoolConverter(source interface{}) (interface{}, error)
- func DefaultNullTimeConverter(source interface{}) (interface{}, error)
- func DefaultTimeConverter(source interface{}) (interface{}, error)
- func Int64ToBool(source interface{}) (interface{}, error)
- func Int64ToNullTime(source interface{}) (interface{}, error)
- func Int64ToTime(source interface{}) (interface{}, error)
- func StringToBool(source interface{}) (interface{}, error)
- func StringToNullTime(source interface{}) (interface{}, error)
- func StringToTime(source interface{}) (interface{}, error)
- func TimeToNullTime(source interface{}) (interface{}, error)
- func TimeToTime(source interface{}) (interface{}, error)
- type ConverterFunc
- type Registry
- func (r *Registry) Convert(source interface{}, targetType reflect.Type) (interface{}, error)
- func (r *Registry) CreateScanner(targetType reflect.Type) sql.Scanner
- func (r *Registry) NeedsConversion(sourceType, targetType reflect.Type) bool
- func (r *Registry) Register(sourceType, targetType reflect.Type, converter ConverterFunc)
- func (r *Registry) RegisterDefault(targetType reflect.Type, converter ConverterFunc)
- type TypePair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBoolConverter ¶
func DefaultBoolConverter(source interface{}) (interface{}, error)
DefaultBoolConverter handles multiple source types for bool target
func DefaultNullTimeConverter ¶
func DefaultNullTimeConverter(source interface{}) (interface{}, error)
DefaultNullTimeConverter handles multiple source types for sql.NullTime target
func DefaultTimeConverter ¶
func DefaultTimeConverter(source interface{}) (interface{}, error)
DefaultTimeConverter handles multiple source types for time.Time target
func Int64ToBool ¶
func Int64ToBool(source interface{}) (interface{}, error)
Int64ToBool converts SQLite integer (0/1) to bool
func Int64ToNullTime ¶
func Int64ToNullTime(source interface{}) (interface{}, error)
Int64ToNullTime converts Unix timestamp (int64) to sql.NullTime
func Int64ToTime ¶
func Int64ToTime(source interface{}) (interface{}, error)
Int64ToTime converts Unix timestamp (int64) to time.Time
func StringToBool ¶
func StringToBool(source interface{}) (interface{}, error)
StringToBool converts string to bool
func StringToNullTime ¶
func StringToNullTime(source interface{}) (interface{}, error)
StringToNullTime converts a string to sql.NullTime
func StringToTime ¶
func StringToTime(source interface{}) (interface{}, error)
StringToTime converts a string to time.Time Tries multiple common formats
func TimeToNullTime ¶
func TimeToNullTime(source interface{}) (interface{}, error)
TimeToNullTime converts time.Time to sql.NullTime
func TimeToTime ¶
func TimeToTime(source interface{}) (interface{}, error)
TimeToTime is a pass-through converter (for completeness)
Types ¶
type ConverterFunc ¶
type ConverterFunc func(source interface{}) (interface{}, error)
ConverterFunc is a function that converts a source value to a target type
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages type conversions between database types and Go types
func (*Registry) Convert ¶
Convert converts a source value to the target type using registered converters
func (*Registry) CreateScanner ¶
CreateScanner creates a sql.Scanner that can handle conversion to the target type
func (*Registry) NeedsConversion ¶
NeedsConversion checks if a conversion is needed for the given type pair
func (*Registry) Register ¶
func (r *Registry) Register(sourceType, targetType reflect.Type, converter ConverterFunc)
Register registers a specific converter for a source->target type pair
func (*Registry) RegisterDefault ¶
func (r *Registry) RegisterDefault(targetType reflect.Type, converter ConverterFunc)
RegisterDefault registers a default converter for a target type This converter will be used when no specific converter is found