Documentation
¶
Index ¶
- Variables
- func FieldType(in interface{}, fieldName string) (reflect.Type, error)
- func GetStringField(in interface{}, fieldName string) (string, error)
- func HasField(in interface{}, fieldName string) bool
- func Override(in interface{}, fieldName string, inval interface{}) error
- func Shift(slice []string) (head string, tail []string)
- func ShiftPath(p string) (head, tail string)
- func StringToType(value string, tpe reflect.Type) (interface{}, error)
- func TypeString(in interface{}) string
Constants ¶
This section is empty.
Variables ¶
var ErrNotAStructPointer = errors.New("given interface is not a struct pointer")
ErrNotAStructPointer self explanatory
Functions ¶
func FieldType ¶
FieldType takes a pointer to a struct and a field name, returns the type of the field in the struct.
func GetStringField ¶
GetStringField given a struct and a fieldName corresponding to a string value returns the string of the field. If field is not a string, will return string value of field.
func HasField ¶
HasField returns true if given a struct that has a field by the name fieldName, returns false otherwise.
func Override ¶
Override takes a pointer to a struct, a field and a value, and overrides the field of the struct with the value.
func Shift ¶
Shift returns the head and tail of a string slice, given an empty list it will return ("", nil).
func ShiftPath ¶
ShiftPath returns the head and tail of a string of form "a/b/c/d", in this case "a" and "/b/c/d"
func StringToType ¶
StringToType will given a string and a type try to return a value of the given type derived from the string. not robust, only works for string, bool and int.
Types ¶
This section is empty.