Documentation
¶
Index ¶
- func AppendMatchingProperties(dst []interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
- func AppendProperties(dst interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
- func Bool(b *bool) bool
- func BoolPtr(b bool) *bool
- func CloneEmptyProperties(structValue reflect.Value) reflect.Value
- func CloneProperties(structValue reflect.Value) reflect.Value
- func CopyProperties(dstValue, srcValue reflect.Value)
- func FieldNameForProperty(propertyName string) string
- func HasTag(field reflect.StructField, name, value string) bool
- func PrependMatchingProperties(dst []interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
- func PrependProperties(dst interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
- func PropertyNameForField(fieldName string) string
- func String(s *string) string
- func StringPtr(s string) *string
- func TypeEqual(s1, s2 interface{}) bool
- func ZeroProperties(structValue reflect.Value)
- type ExtendPropertyError
- type ExtendPropertyFilterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendMatchingProperties ¶
func AppendMatchingProperties(dst []interface{}, src interface{},
filter ExtendPropertyFilterFunc) error
AppendMatchingProperties appends the values of properties in the property struct src to the property structs in dst. dst and src do not have to be the same type, but every property in src must be found in at least one property in dst. dst must be a slice of pointers to structs, and src must be a pointer to a struct.
The filter function can prevent individual properties from being appended by returning false, or abort AppendProperties with an error by returning an error. Passing nil for filter will append all properties.
An error returned by AppendMatchingProperties that applies to a specific property will be an *ExtendPropertyError, and can have the property name and error extracted from it.
The append operation is defined as appending strings, and slices of strings normally, OR-ing bool values, replacing non-nil pointers to booleans or strings, and recursing into embedded structs, pointers to structs, and interfaces containing pointers to structs. Appending the zero value of a property will always be a no-op.
func AppendProperties ¶
func AppendProperties(dst interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
AppendProperties appends the values of properties in the property struct src to the property struct dst. dst and src must be the same type, and both must be pointers to structs.
The filter function can prevent individual properties from being appended by returning false, or abort AppendProperties with an error by returning an error. Passing nil for filter will append all properties.
An error returned by AppendProperties that applies to a specific property will be an *ExtendPropertyError, and can have the property name and error extracted from it.
The append operation is defined as appending strings and slices of strings normally, OR-ing bool values, replacing non-nil pointers to booleans or strings, and recursing into embedded structs, pointers to structs, and interfaces containing pointers to structs. Appending the zero value of a property will always be a no-op.
func Bool ¶
Bool takes a pointer to a bool and returns true iff the pointer is non-nil and points to a true value.
func CopyProperties ¶
func FieldNameForProperty ¶
func PrependMatchingProperties ¶
func PrependMatchingProperties(dst []interface{}, src interface{},
filter ExtendPropertyFilterFunc) error
PrependMatchingProperties prepends the values of properties in the property struct src to the property structs in dst. dst and src do not have to be the same type, but every property in src must be found in at least one property in dst. dst must be a slice of pointers to structs, and src must be a pointer to a struct.
The filter function can prevent individual properties from being prepended by returning false, or abort PrependProperties with an error by returning an error. Passing nil for filter will prepend all properties.
An error returned by PrependProperties that applies to a specific property will be an *ExtendPropertyError, and can have the property name and error extracted from it.
The prepend operation is defined as prepending strings, and slices of strings normally, OR-ing bool values, replacing non-nil pointers to booleans or strings, and recursing into embedded structs, pointers to structs, and interfaces containing pointers to structs. Prepending the zero value of a property will always be a no-op.
func PrependProperties ¶
func PrependProperties(dst interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
PrependProperties prepends the values of properties in the property struct src to the property struct dst. dst and src must be the same type, and both must be pointers to structs.
The filter function can prevent individual properties from being prepended by returning false, or abort PrependProperties with an error by returning an error. Passing nil for filter will prepend all properties.
An error returned by PrependProperties that applies to a specific property will be an *ExtendPropertyError, and can have the property name and error extracted from it.
The prepend operation is defined as prepending strings, and slices of strings normally, OR-ing bool values, replacing non-nil pointers to booleans or strings, and recursing into embedded structs, pointers to structs, and interfaces containing pointers to structs. Prepending the zero value of a property will always be a no-op.
func PropertyNameForField ¶
func String ¶
String takes a pointer to a string and returns the value of the string if the pointer is non-nil, or an empty string.
func TypeEqual ¶
func TypeEqual(s1, s2 interface{}) bool
TypeEqual takes two property structs, and returns true if they are of equal type, any embedded pointers to structs or interfaces having matching nilitude, and any interface{} values in any embedded structs, pointers to structs, or interfaces are also of equal type.
func ZeroProperties ¶
Types ¶
type ExtendPropertyError ¶
func (*ExtendPropertyError) Error ¶
func (e *ExtendPropertyError) Error() string
type ExtendPropertyFilterFunc ¶
type ExtendPropertyFilterFunc func(property string, dstField, srcField reflect.StructField, dstValue, srcValue interface{}) (bool, error)