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 BoolDefault(b *bool, def 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 ExtendBasicType(dstFieldValue, srcFieldValue reflect.Value, order Order)
- func ExtendMatchingProperties(dst []interface{}, src interface{}, filter ExtendPropertyFilterFunc, ...) error
- func ExtendProperties(dst interface{}, src interface{}, filter ExtendPropertyFilterFunc, ...) error
- func FieldNameForProperty(propertyName string) string
- func HasTag(field reflect.StructField, name, value string) bool
- func Int64Ptr(i int64) *int64
- func NinjaAndShellEscape(slice []string) []string
- func NinjaEscape(slice []string) []string
- func PrependMatchingProperties(dst []interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
- func PrependProperties(dst interface{}, src interface{}, filter ExtendPropertyFilterFunc) error
- func PropertyNameForField(fieldName string) string
- func ShellEscape(slice []string) []string
- func String(s *string) string
- func StringDefault(s *string, def string) string
- func StringPtr(s string) *string
- func TypeEqual(s1, s2 interface{}) bool
- func ZeroProperties(structValue reflect.Value)
- type ExtendPropertyError
- type ExtendPropertyFilterFunc
- type ExtendPropertyOrderFunc
- type Order
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 BoolDefault ¶
BoolDefault takes a pointer to a bool and returns the value pointed to by the pointer if it is non-nil, or def if the pointer is nil.
func CopyProperties ¶
func ExtendBasicType ¶
func ExtendMatchingProperties ¶
func ExtendMatchingProperties(dst []interface{}, src interface{}, filter ExtendPropertyFilterFunc, order ExtendPropertyOrderFunc) error
ExtendMatchingProperties appends or 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 appended or prepended by returning false, or abort ExtendMatchingProperties with an error by returning an error. Passing nil for filter will append or prepend all properties.
The order function is called on each non-filtered property to determine if it should be appended or prepended.
An error returned by ExtendMatchingProperties 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 or prepending the zero value of a property will always be a no-op.
func ExtendProperties ¶
func ExtendProperties(dst interface{}, src interface{}, filter ExtendPropertyFilterFunc, order ExtendPropertyOrderFunc) error
ExtendProperties appends or 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 appended or prepended by returning false, or abort ExtendProperties with an error by returning an error. Passing nil for filter will append or prepend all properties.
The order function is called on each non-filtered property to determine if it should be appended or prepended.
An error returned by ExtendProperties 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 or prepending the zero value of a property will always be a no-op.
func FieldNameForProperty ¶
func NinjaAndShellEscape ¶
func NinjaEscape ¶
NinjaEscape takes a slice of strings that may contain characters that are meaningful to ninja ($), and escapes each string so they will be passed to bash. It is not necessary on input, output, or dependency names, those are handled by ModuleContext.Build. It is generally required on strings from properties in Blueprint files that are used as Args to ModuleContext.Build. A new slice containing the escaped strings is returned.
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 ShellEscape ¶
ShellEscape takes a slice of strings that may contain characters that are meaningful to bash and escapes if necessary by wrapping them in single quotes, and replacing internal single quotes with '\” (one single quote to end the quoting, a shell-escaped single quote to insert a real single quote, and then a single quote to restarting quoting. A new slice containing the escaped strings is returned.
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 StringDefault ¶
String takes a pointer to a string and returns the value of the string if the pointer is non-nil, or def if the pointer is nil.
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)
type ExtendPropertyOrderFunc ¶
type ExtendPropertyOrderFunc func(property string, dstField, srcField reflect.StructField, dstValue, srcValue interface{}) (Order, error)