reflects

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 4 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// Int for all intX types
	Int = BKind(reflect.Int)
	// Uint for all uintX types
	Uint = BKind(reflect.Uint)
	// Float for all floatX types
	Float = BKind(reflect.Float32)
	// Array for array,slice types
	Array = BKind(reflect.Array)
	// Complex for all complexX types
	Complex = BKind(reflect.Complex64)
)

base kinds

Variables

This section is empty.

Functions

func Elem

func Elem(v reflect.Value) reflect.Value

Elem returns the value that the interface v contains or that the pointer v points to.

func HasChild added in v0.5.6

func HasChild(v reflect.Value) bool

HasChild check. eg: array, slice, map, struct

func IsEmpty added in v0.5.6

func IsEmpty(v reflect.Value) bool

IsEmpty reflect value check

func IsEmptyValue added in v0.5.8

func IsEmptyValue(v reflect.Value) bool

IsEmptyValue reflect value check. From src/pkg/encoding/json/encode.go.

func IsEqual added in v0.5.6

func IsEqual(src, dst interface{}) bool

IsEqual determines if two objects are considered equal.

TIP: cannot compare function type

func IsFunc added in v0.5.6

func IsFunc(val interface{}) bool

IsFunc value

func IsNil added in v0.5.6

func IsNil(v reflect.Value) bool

IsNil reflect value

func Len added in v0.5.6

func Len(v reflect.Value) int

Len get reflect value length

func SliceSubKind added in v0.5.8

func SliceSubKind(typ reflect.Type) reflect.Kind

SliceSubKind get sub-elem kind of the array, slice, variadic-var.

Usage:

SliceSubKind(reflect.TypeOf([]string{"abc"})) // reflect.String

Types

type BKind

type BKind uint

BKind base data kind type

func ToBKind added in v0.5.6

func ToBKind(kind reflect.Kind) BKind

ToBKind convert reflect.Kind to base kind

func ToBaseKind

func ToBaseKind(kind reflect.Kind) BKind

ToBaseKind convert reflect.Kind to base kind

type Type

type Type interface {
	reflect.Type
	// BaseKind value
	BaseKind() BKind
}

Type struct

func TypeOf

func TypeOf(v interface{}) Type

TypeOf value

type Value

type Value struct {
	reflect.Value
	// contains filtered or unexported fields
}

Value struct

func ValueOf

func ValueOf(v interface{}) Value

ValueOf the give value

func Wrap

func Wrap(rv reflect.Value) Value

Wrap the give value

func (Value) BKind added in v0.5.6

func (v Value) BKind() BKind

BKind value

func (Value) BaseKind

func (v Value) BaseKind() BKind

BaseKind value

func (Value) Elem

func (v Value) Elem() Value

Elem returns the value that the interface v contains or that the pointer v points to.

TIP: not like reflect.Value.Elem. otherwise, will return self.

func (Value) HasChild added in v0.5.6

func (v Value) HasChild() bool

HasChild check. eg: array, slice, map, struct

func (Value) Indirect

func (v Value) Indirect() Value

Indirect value. alias of the reflect.Indirect()

func (Value) Int added in v0.5.6

func (v Value) Int() int64

Int value. if is uintX will convert to int64

func (Value) Type

func (v Value) Type() Type

Type of value.

func (Value) Uint added in v0.5.6

func (v Value) Uint() uint64

Uint value. if is intX will convert to uint64

Jump to

Keyboard shortcuts

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