Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Only ¶
Only extracts the requested field from the given map[string] or structure and returns a map[string]any containing only those values.
For example:
type Model struct { Field string Num int Slice []float64 } model := Model{ Field: "value", Num: 42, Slice: []float64{3, 6, 9}, } res := reflectutil.Only(model, "Field", "Slice")
Result:
map[string]any{ "Field": "value", "Slice": []float64{3, 6, 9}, }
In case of conflicting fields (if a promoted field has the same name as a parent's struct field), the higher level field is kept.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.