Documentation ¶
Index ¶
- Variables
- func IsConvertible(v reflect.Value, target reflect.Type) bool
- func IsStruct(t reflect.Type) bool
- func IsTypeOrConvertible(v reflect.Value, target reflect.Type) (bool, bool)
- func KindType(val reflect.Value) string
- func NewOrder(t reflect.Type) func(a, b reflect.Value) int
- type OperatorNotJSONMarshallableError
- type RawInt
- type RawString
- type RecvKind
- type TestDeepStamp
- type TestDeepStringer
Constants ¶
This section is empty.
Variables ¶
var ( Bool = reflect.TypeOf(false) Interface = reflect.TypeOf((*any)(nil)).Elem() SliceInterface = reflect.TypeOf(([]any)(nil)) FmtStringer = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() Error = reflect.TypeOf((*error)(nil)).Elem() JsonUnmarshaler = reflect.TypeOf((*json.Unmarshaler)(nil)).Elem() //nolint: revive Time = reflect.TypeOf(time.Time{}) Int = reflect.TypeOf(int(0)) Uint8 = reflect.TypeOf(uint8(0)) Rune = reflect.TypeOf(rune(0)) String = reflect.TypeOf("") )
Functions ¶
func IsConvertible ¶ added in v1.11.0
IsConvertible returns true if v is convertible to target type, false otherwise.
It handles go 1.17 slice to array pointer convertibility. It handles go 1.20 slice to array convertibility.
func IsStruct ¶ added in v1.8.0
IsStruct returns true if t is a struct or a pointer on a struct (whatever the number of chained pointers), false otherwise.
func IsTypeOrConvertible ¶ added in v1.11.0
IsTypeOrConvertible returns (true, false) if v type == target, (true, true) if v if convertible to target type, (false, false) otherwise.
It handles go 1.17 slice to array pointer convertibility.
func KindType ¶ added in v1.13.0
KindType returns the kind of val as a string. If the kind is reflect.Ptr, a "*" is used as prefix of kind of val.Type().Elem(), and so on. If the final kind differs from val.Type(), the type is appended inside parenthesis.
Types ¶
type OperatorNotJSONMarshallableError ¶ added in v1.9.2
type OperatorNotJSONMarshallableError string
OperatorNotJSONMarshallableError implements error interface. It is returned by (*td.TestDeep).MarshalJSON() to notice the user an operator cannot be JSON Marshal'ed.
func AsOperatorNotJSONMarshallableError ¶ added in v1.9.2
func AsOperatorNotJSONMarshallableError(err error) (OperatorNotJSONMarshallableError, bool)
AsOperatorNotJSONMarshallableError checks that err is or contains an OperatorNotJSONMarshallableError and if yes, returns it and true.
func (OperatorNotJSONMarshallableError) Error ¶ added in v1.9.2
func (e OperatorNotJSONMarshallableError) Error() string
Error implements error interface.
func (OperatorNotJSONMarshallableError) Operator ¶ added in v1.9.2
func (e OperatorNotJSONMarshallableError) Operator() string
Operator returns the operator behind this error.
type TestDeepStamp ¶
type TestDeepStamp struct{}
TestDeepStamp is a useful type providing the _TestDeep() method needed to implement TestDeepStringer interface.
type TestDeepStringer ¶
type TestDeepStringer interface { String() string // contains filtered or unexported methods }
TestDeepStringer is a TestDeep specific interface for objects which know how to stringify themselves.