types

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2023 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func IsConvertible(v reflect.Value, target reflect.Type) bool

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

func IsStruct(t reflect.Type) bool

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

func IsTypeOrConvertible(v reflect.Value, target reflect.Type) (bool, bool)

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

func KindType(val reflect.Value) string

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.

func NewOrder added in v1.11.0

func NewOrder(t reflect.Type) func(a, b reflect.Value) int

NewOrder returns a function able to compare 2 non-nil values of type t. It returns nil if the type t is not comparable.

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

Error implements error interface.

func (OperatorNotJSONMarshallableError) Operator added in v1.9.2

Operator returns the operator behind this error.

type RawInt

type RawInt int

RawInt implements TestDeepStringer interface.

func (RawInt) String

func (i RawInt) String() string

type RawString

type RawString string

RawString implements TestDeepStringer interface.

func (RawString) String

func (s RawString) String() string

type RecvKind added in v1.13.0

type RecvKind bool
const (
	RecvNothing RecvKind
	RecvClosed
)

func (RecvKind) String added in v1.13.0

func (r RecvKind) String() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL