reflect

package
v3.15.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2018 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	/**
	 * Buildin types
	 */
	HashTypeOfInt    = DigestType(TypeOfInt)
	HashTypeOfInt64  = DigestType(TypeOfInt64)
	HashTypeOfInt32  = DigestType(TypeOfInt32)
	HashTypeOfInt16  = DigestType(TypeOfInt16)
	HashTypeOfInt8   = DigestType(TypeOfInt8)
	HashTypeOfUint   = DigestType(TypeOfUint)
	HashTypeOfUint64 = DigestType(TypeOfUint64)
	HashTypeOfUint32 = DigestType(TypeOfUint32)
	HashTypeOfUint16 = DigestType(TypeOfUint16)
	HashTypeOfUint8  = DigestType(TypeOfUint8)

	HashTypeOfFloat32 = DigestType(TypeOfFloat32)
	HashTypeOfFloat64 = DigestType(TypeOfFloat64)

	HashTypeOfComplex64  = DigestType(TypeOfComplex64)
	HashTypeOfComplex128 = DigestType(TypeOfComplex128)

	HashTypeOfByte   = DigestType(TypeOfByte)
	HashTypeOfBool   = DigestType(TypeOfBool)
	HashTypeOfString = DigestType(TypeOfString)

	/**
	 * Slice Types
	 */
	HashPTypeOfInt    = DigestType(PTypeOfInt)
	HashPTypeOfInt64  = DigestType(PTypeOfInt64)
	HashPTypeOfInt32  = DigestType(PTypeOfInt32)
	HashPTypeOfInt16  = DigestType(PTypeOfInt16)
	HashPTypeOfInt8   = DigestType(PTypeOfInt8)
	HashPTypeOfUint   = DigestType(PTypeOfUint)
	HashPTypeOfUint64 = DigestType(PTypeOfUint64)
	HashPTypeOfUint32 = DigestType(PTypeOfUint32)
	HashPTypeOfUint16 = DigestType(PTypeOfUint16)
	HashPTypeOfUint8  = DigestType(PTypeOfUint8)

	HashPTypeOfFloat32 = DigestType(PTypeOfFloat32)
	HashPTypeOfFloat64 = DigestType(PTypeOfFloat64)

	HashPTypeOfComplex64  = DigestType(PTypeOfComplex64)
	HashPTypeOfComplex128 = DigestType(PTypeOfComplex128)

	HashPTypeOfByte   = DigestType(PTypeOfByte)
	HashPTypeOfBool   = DigestType(PTypeOfBool)
	HashPTypeOfString = DigestType(PTypeOfString)

	/**
	 * Slice type
	 */
	HashSTypeOfInt    = DigestType(STypeOfInt)
	HashSTypeOfInt64  = DigestType(STypeOfInt64)
	HashSTypeOfInt32  = DigestType(STypeOfInt32)
	HashSTypeOfInt16  = DigestType(STypeOfInt16)
	HashSTypeOfInt8   = DigestType(STypeOfInt8)
	HashSTypeOfUint   = DigestType(STypeOfUint)
	HashSTypeOfUint64 = DigestType(STypeOfUint64)
	HashSTypeOfUint32 = DigestType(STypeOfUint32)
	HashSTypeOfUint16 = DigestType(STypeOfUint16)
	HashSTypeOfUint8  = DigestType(STypeOfUint8)

	HashSTypeOfFloat32 = DigestType(STypeOfFloat32)
	HashSTypeOfFloat64 = DigestType(STypeOfFloat64)

	HashSTypeOfComplex64  = DigestType(STypeOfComplex64)
	HashSTypeOfComplex128 = DigestType(STypeOfComplex128)

	HashSTypeOfByte   = DigestType(STypeOfByte)
	HashSTypeOfBool   = DigestType(STypeOfBool)
	HashSTypeOfString = DigestType(STypeOfString)
)

Hash values of reflect.Type

View Source
var TypeOfReflectType = TypeOfInterface((*reflect.Type)(nil))

Functions

func DigestType

func DigestType(t reflect.Type) uint64

Used to generate digest information of a type.

The hash value of reflect.Type could be used to generate key of map on reflect.Type, which has better performance on look-up operation on map.

algorithms for generating byte array of source:

1. UTF-8 Type.PkgPath() 2. UTF-8 Type.String()

The algorithms of hashing: hash/fnv.New64()

func FinalPointedType

func FinalPointedType(pointerType reflect.Type) reflect.Type

Gets the final pointed type of a pointer type

func FinalPointedValue

func FinalPointedValue(pointerValue reflect.Value) reflect.Value

Gets the final value of pointer, it may be IsNil()

func GetAllTypesForFunction

func GetAllTypesForFunction(funcType reflect.Type) (inputTypes []reflect.Type, outputTypes []reflect.Type)

Gets the types of a function

This function gives the slice of types for both of input and output

func GetValueOfField

func GetValueOfField(v interface{}, tree ...string) interface{}

Gets value of field, supporting tree visiting whether or not the value is struct or pointer to struct.

func GetValueOfFieldByReflect

func GetValueOfFieldByReflect(v reflect.Value, tree ...string) reflect.Value

Gets value of field, supported tree visiting whether or not the value is struct or pointer to struct.

func IsReflectType

func IsReflectType(v interface{}) bool

Checks if the value is type of reflect.Type

func NewFinalValue

func NewFinalValue(startType reflect.Type) reflect.Value

new() a value by pass through multi-layer pointers

func NewFinalValueFrom

func NewFinalValueFrom(fromValue reflect.Value, finalTypeOfPointer reflect.Type) reflect.Value

func NewPointerValue

func NewPointerValue(targetValue interface{}) interface{}

func SetValueOfField

func SetValueOfField(v interface{}, newFieldValue interface{}, tree ...string)

Sets value of field, supporting tree visiting whether or not the value is struct or pointer to struct.

func SetValueOfFieldByReflect

func SetValueOfFieldByReflect(v reflect.Value, newFieldValue reflect.Value, tree ...string)

Sets value of field, supporting tree visiting whether or not the value is struct or pointer to struct.

func TypeOfInterface

func TypeOfInterface(v interface{}) reflect.Type

Gets the type of interface, which is short function of:

reflect.TypeOf(nilPointerToInterface).Elem()

func TypeOfValue

func TypeOfValue(v interface{}) reflect.Type

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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