Documentation
¶
Overview ¶
Package matcher implements field matching between source and destination structs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
TagKey string // struct tag key for field renaming (default: "map")
Strict bool // fail if any destination field is unmapped
Verbose bool // print matching decisions
CaseInsensitive bool // match fields by case-insensitive name comparison
}
Config controls matching behavior.
type FieldMapping ¶
type FieldMapping struct {
SrcAccessor string // e.g. "src.Name" or "src.Address.Street"
DstField string // destination field name, e.g. "Name"
NeedsConv bool // true if type conversion is needed
ConvType string // destination type string for conversion, e.g. "int64"
Deref bool // prepend * to accessor (src is *T, dst is T)
DstTypeName string // destination type name for nil-safe declarations (set when Deref=true)
AddrOf bool // prepend & to accessor (src is T, dst is *T)
IsSliceMap bool // use mapper.MapSlice for []T → []U
SliceSrc string // source element base type name (for MapXToY function name)
SliceDst string // destination element base type name (for MapXToY function name)
SliceDstFull string // full destination element type (for make[], may include *)
IsStructMap bool // nested struct mapping (different named struct types)
StructSrc string // source struct type name
StructDst string // destination struct type name
SliceElemDeref bool // dereference source element in slice loop
SliceElemAddrOf bool // addr-of result in slice loop
SliceElemConv bool // type-convert element in slice loop (no map function)
SliceElemConvType string // conversion type for slice element
}
FieldMapping represents a matched pair of fields between source and destination.
type NestedDstAssignment ¶
type NestedDstAssignment struct {
DstPath string // e.g., "Address.Street"
SrcAccessor string // e.g., "Street"
NeedsConv bool
ConvType string
}
NestedDstAssignment represents a source field mapped to a nested destination path via a source-side tag like `map:"Address.Street"`. Generated as: result.DstPath = src.SrcAccessor (with optional conversion).
type Result ¶
type Result struct {
Mappings []FieldMapping
Unmapped []UnmappedField
NestedDstAssignments []NestedDstAssignment
}
Result holds the matching outcome for a struct pair.
type UnmappedField ¶
UnmappedField represents a destination field that could not be matched.
Click to show internal directories.
Click to hide internal directories.