Documentation
¶
Index ¶
- func CamelCaseToUnderscore(name string) string
- func CanBool(v reflect.Value) bool
- func CanBytes(v reflect.Value) bool
- func CanComplex(v reflect.Value) bool
- func CanDuration(v reflect.Value) bool
- func CanError(v reflect.Value) bool
- func CanFloat(v reflect.Value) bool
- func CanInt(v reflect.Value) bool
- func CanInterface(v reflect.Value) bool
- func CanMap(v reflect.Value) bool
- func CanNil(v reflect.Value) bool
- func CanPtr(v reflect.Value) bool
- func CanSlice(v reflect.Value) bool
- func CanString(v reflect.Value) bool
- func CanStruct(v reflect.Value) bool
- func CanTime(v reflect.Value) bool
- func CanUint(v reflect.Value) bool
- func Duration(v reflect.Value) (d time.Duration)
- func Error(v reflect.Value) error
- func IndirectType(v reflect.Value) reflect.Type
- func Kinds(kinds ...reflect.Kind) string
- func PresetIndirect(v reflect.Value) reflect.Value
- func StringToTime(s string) (t time.Time, err error)
- func Time(v reflect.Value) (t time.Time)
- func Zero(v reflect.Value) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCaseToUnderscore ¶ added in v1.0.4
CamelCaseToUnderscore converts CamelCase to under_score style.
Copied from: https://gist.github.com/zxh/cee082053aa9674812e8cd4387088301
Improvement upon default approach, which is:
import "github.com/asaskevich/govalidator" return govalidator.CamelCaseToUnderscore(f.field.Name)
func CanComplex ¶
CanComplex returns true if reflect value is of type float.
func CanDuration ¶
CanDuration returns true if reflect value is of type time.Duration, else returns false.
NOTE: time.Duration <=> int64
func CanInterface ¶
CanInterface reports whether reflect Interface can be used on reflect value without panicking.
func CanNil ¶
CanNil returns true if reflect value represents a type that can be set to nil, else returns false.
func CanSlice ¶
CanSlice reports whether reflect Slice can be used on reflect value without panicking.
func CanStruct ¶
CanStruct returns true if reflect value represents a nested struct, else returns false.
func IndirectType ¶ added in v1.0.6
IndirectType returns the type that v points to. If v is a pointer, IndirectType returns the type v points to. If v is not a pointer, IndirectType returns the type of v.
func PresetIndirect ¶ added in v1.0.6
PresetIndirect returns the value that v points to (like reflect.Indirect). If v is a nil pointer, PresetIndirect returns a zero Value. If v is not a pointer, PresetIndirect returns v.
Unlike in reflect.Indirect, if v was a nil pointer, v does not stay a nil pointer. Now v points to the zero Value returned. Useful when preparing v just before setting its conrete value.
Example:
if v is nil pointer to string, PresetIndirect returns "" and v points to "".
Types ¶
This section is empty.