Documentation ¶
Overview ¶
Utilities for working with and manipulating structs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var StopIterating = errors.New(`stop iterating`)
Functions ¶
func CopyFunc ¶
func CopyFunc(dest interface{}, source interface{}, fn StructValueFunc) error
func CopyNonZero ¶
func CopyNonZero(dest interface{}, source interface{}) error
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 interface{}, fn StructFieldFunc) error
Iterates over all exported and embedded fields in the given struct, calling fn for each field.
Types ¶
type StructFieldFunc ¶ added in v1.7.52
type StructFieldFunc func(field *reflect.StructField, value reflect.Value) error
type StructValueFunc ¶
type StructValueFunc func(field string, sourceValue interface{}, destValue interface{}) (interface{}, bool)
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.
Click to show internal directories.
Click to hide internal directories.