reflex

package
v12.2.11 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StringType            = reflect.TypeOf("")
	BytesType             = reflect.TypeOf([]byte{})
	IntType               = reflect.TypeOf(int(0))
	Int16Type             = reflect.TypeOf(int16(0))
	Int32Type             = reflect.TypeOf(int32(0))
	Int64Type             = reflect.TypeOf(int64(0))
	Float32Type           = reflect.TypeOf(float32(0))
	Float64Type           = reflect.TypeOf(float64(0))
	TimeType              = reflect.TypeOf(time.Time{})
	IpTyp                 = reflect.TypeOf(net.IP{})
	JSONNumberTyp         = reflect.TypeOf(json.Number(""))
	StringerTyp           = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
	ArrayIntegerTyp       = reflect.TypeOf([]int{})
	ArrayStringTyp        = reflect.TypeOf([]string{})
	DoubleArrayIntegerTyp = reflect.TypeOf([][]int{})
	DoubleArrayStringTyp  = reflect.TypeOf([][]string{})
	ErrTyp                = reflect.TypeOf((*error)(nil)).Elem()
)

Common reflect types for go standard data types.

Functions

func IndirectType

func IndirectType(typ reflect.Type) reflect.Type

IndirectType returns the value of a pointer-type "typ". If "IndirectType" is a pointer, array, chan, map or slice it returns its Elem, otherwise returns the "typ" as it is.

func IndirectValue

func IndirectValue(val reflect.Value) reflect.Value

IndirectValue returns the element type (e.g. if pointer of *User it will return the User type).

func IsError

func IsError(typ interface{ Implements(reflect.Type) bool }) bool

IsError reports whether "typ" is an error type.

func IsFunc

func IsFunc(typ interface{ Kind() reflect.Kind }) bool

IsFunc reports whether the "kindable" is a type of function.

func IsZero

func IsZero(v interface{}) bool

IsZero reports whether "v" is zero value or no. The given "v" value can complete the Zeroer interface which can be used to customize the behavior for each type of "v".

func LookupFields

func LookupFields(typ reflect.Type, fieldTag string) []reflect.StructField

LookupFields returns a slice of all fields containing a struct field of the given "fieldTag" of the "typ" struct. The fields returned are flatted and reclusive over fields with value of struct. Panics if "typ" is not a type of Struct.

func LookupUnderlineValueType

func LookupUnderlineValueType(v reflect.Value) (reflect.Value, reflect.Type)

LookupUnderlineValueType returns the underline type of "v".

Types

type FuncParam

type FuncParam struct {
	Index int
	Type  reflect.Type
}

FuncParam holds the properties of function input or output.

func LookupInputs

func LookupInputs(fn reflect.Type) []FuncParam

LookupInputs returns the index and type of each function's input argument. Panics if "fn" is not a type of Func.

func LookupOutputs

func LookupOutputs(fn reflect.Type) []FuncParam

LookupOutputs returns the index and type of each function's output argument. Panics if "fn" is not a type of Func.

type Zeroer

type Zeroer interface {
	IsZero() bool
}

Zeroer can be implemented by custom types to report whether its current value is zero. Standard Time also implements that.

Jump to

Keyboard shortcuts

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