Documentation
¶
Overview ¶
Package conv provides a configurable, reflection-based type converter. It supports primitives, slices, maps, structs, pointer cloning, time parsing, and custom conversion functions registered per source/destination type.
Index ¶
Constants ¶
const DefaultDateLayout = "2006-01-02 15:04:05.000"
DefaultDateLayout is the default layout used for time parsing when no layout is specified
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConversionFunc ¶
ConversionFunc defines a custom conversion function
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter provides type conversion functionality
func NewConverter ¶
NewConverter creates a new type converter with the provided options
func (*Converter) Convert ¶
Convert converts the source value to the destination value Changed signature to take destination as second parameter
func (*Converter) RegisterConversion ¶
func (c *Converter) RegisterConversion(srcType, destType reflect.Type, fn ConversionFunc)
RegisterConversion registers a custom conversion function between source and destination types
type Options ¶
type Options struct {
// DateLayout specifies the layout for time parsing
DateLayout string
// TagName is the struct tag name to look for mapping information
TagName string
// CaseSensitive controls whether field/key matching is case sensitive
CaseSensitive bool
// IgnoreUnmapped controls whether to ignore unmapped fields
IgnoreUnmapped bool
// ClonePointerData if true, creates a clone of data pointed by pointers
ClonePointerData bool
// AccessUnexported if true, allows accessing unexported fields
AccessUnexported bool
}
Options contains configuration for the converter
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns default conversion options