Documentation
¶
Overview ¶
Utilities for working with and manipulating structs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var StopIterating = errors.New(`stop iterating`)
var StructTag string = `structutil`
Functions ¶
func CopyNonZero ¶
Copy all values from the source into the destination, provided the source value for the corresponding field is not that type's zero value.
func FieldsFunc ¶ added in v1.7.52
func FieldsFunc(in any, fn StructFieldFunc) error
Iterates over all exported and embedded fields in the given struct, calling fn for each field.
Types ¶
type Field ¶ added in v1.8.92
type Field struct {
*reflect.StructField
Struct *Struct
}
func (*Field) GetTag ¶ added in v1.9.9
Retrieve the field name and attributes associated with the given field tag.
func (*Field) MergeValue ¶ added in v1.8.92
type Struct ¶ added in v1.8.92
type Struct struct {
Source any
// contains filtered or unexported fields
}
A Struct, or "S-object", can be used to rapidly and safely inspect, iterate over, and modify values of a struct.
type StructFieldFunc ¶ added in v1.7.52
type StructFieldFunc func(field *reflect.StructField, value reflect.Value) error
type StructValueFunc ¶
Receives a struct field name, the value of that field in the source struct, and the value for that field in the destination struct. Returns the value that should be placed in the destination struct fields. If the returned bool is false, no changes will be made.