Documentation ¶
Overview ¶
Package reflectutil includes helpers for working with the golang reflection api.
Index ¶
- Constants
- func DecomposeStrings(obj interface{}, tagName ...string) map[string]string
- func FollowValue(v reflect.Value) interface{}
- func IsEmptyValue(v reflect.Value) bool
- func IsExported(fieldName string) bool
- func Patch(obj interface{}, patchValues map[string]interface{}) (err error)
- func PatchStrings(tagName string, data map[string]string, obj interface{}) error
- func PatchStringsFunc(tagName string, getData func(string) (string, bool), obj interface{}) (err error)
- func SetValue(obj interface{}, objType reflect.Type, objValue reflect.Value, ...) (err error)
- func SliceType(collection interface{}) reflect.Type
- func Type(obj interface{}) reflect.Type
- func Value(obj interface{}) reflect.Value
- type PatchStringer
- type PatchStringsFuncer
- type Patcher
Constants ¶
const ( // FieldTagEnv is the struct tag for what environment variable to use to populate a field. FieldTagEnv = "env" // FieldFlagCSV is a field tag flag (say that 10 times fast). FieldFlagCSV = "csv" // FieldFlagBase64 is a field tag flag (say that 10 times fast). FieldFlagBase64 = "base64" // FieldFlagBytes is a field tag flag (say that 10 times fast). FieldFlagBytes = "bytes" )
PatchStrings options.
Variables ¶
This section is empty.
Functions ¶
func DecomposeStrings ¶
DecomposeStrings decomposes an object into a string map.
func FollowValue ¶
FollowValue derefs a reflect.Value until it isn't a pointer, but will preseve it's nilness.
func IsEmptyValue ¶
IsEmptyValue returns if a reflect.Value is empty.
func IsExported ¶
IsExported returns if a field is exported given its name and capitalization.
func PatchStrings ¶
PatchStrings patches an object with a given map of data matched with tags of a given name or the name of the field.
func PatchStringsFunc ¶
func PatchStringsFunc(tagName string, getData func(string) (string, bool), obj interface{}) (err error)
PatchStringsFunc patches an object with a given map of data matched with tags of a given name or the name of the field.
func SetValue ¶
func SetValue(obj interface{}, objType reflect.Type, objValue reflect.Value, fieldName string, value interface{}) (err error)
SetValue sets a value on an object by its field name.
Types ¶
type PatchStringer ¶
PatchStringer is a type that handles unmarshalling a map of strings into itself.
type PatchStringsFuncer ¶
PatchStringsFuncer is a type that handles unmarshalling a map of strings into itself.