reflectinternal

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Uint8sType   = reflect.ValueOf([]byte{}).Type()
	BytesType    = Uint8sType
	StringsType  = reflect.ValueOf([]string{}).Type()
	StringType   = reflect.ValueOf("").Type()
	IntegersType = reflect.ValueOf([]int{}).Type()
	IntegerType  = reflect.ValueOf(0).Type()
	BooleanType  = reflect.ValueOf(false).Type()
	Int64sType   = reflect.ValueOf([]int64{}).Type()
	Float64sType = reflect.ValueOf([]float64{}).Type()
	BooleansType = reflect.ValueOf([]bool{}).Type()
	AnyType      = reflect.ValueOf([]interface{}{}).Type()
)

Functions

func GetElementType

func GetElementType(any interface{}) reflect.Type

Calls GetElementTypeMaxTry with maxTry 4

Examples:

func GetElementTypeMaxTry

func GetElementTypeMaxTry(any interface{}, maxTry int) reflect.Type

Examples:

func GetElementTypesMaxTry

func GetElementTypesMaxTry(any interface{}, maxTries int) (finalType reflect.Type, visitedTypes []reflect.Type)

Examples:

func GetFieldValue

func GetFieldValue(field reflect.Value) interface{}

Example

 actualValueOf := reflect.ValueOf(*actual)
	for i := 0; i < actualValueOf.NumField(); i++ {
		actualFieldValue := GetFieldValue(actualValueOf.Field(i))
		expectedFieldValue := GetFieldValue(reflect.ValueOf(expectedNewEmptyDirectoryResult).Field(i))

func GetTypeName

func GetTypeName(any interface{}) string

func IsBoolean

func IsBoolean(any interface{}) (isBool bool, isResult bool)

func IsBooleanPointer

func IsBooleanPointer(any interface{}) (isBool bool, isResult *bool)

func IsByte

func IsByte(any interface{}) (isByte bool, result byte)

func IsBytesOrBytesPointer

func IsBytesOrBytesPointer(any interface{}) (isBytes bool, bytesPtr *[]byte)

Examples : https://play.golang.org/p/9XUt9Jf11WG | https://play.golang.org/p/oMAxxSzAP7F

func IsFloat64sOrFloat64sPointer

func IsFloat64sOrFloat64sPointer(any interface{}) (isFloat64 bool, floats *[]float64)

func IsInteger

func IsInteger(any interface{}) (isInteger bool, intValue int)

Examples : https://play.golang.org/p/9XUt9Jf11WG | https://play.golang.org/p/oMAxxSzAP7F

func IsIntegerOrIntegerPointer

func IsIntegerOrIntegerPointer(any interface{}) (isInteger bool, intPtr *int)

Examples : https://play.golang.org/p/9XUt9Jf11WG | https://play.golang.org/p/oMAxxSzAP7F

func IsIntegersOrIntegersPointer

func IsIntegersOrIntegersPointer(any interface{}) (isIntegers bool, integersResults *[]int)

Examples : https://play.golang.org/p/9XUt9Jf11WG | https://play.golang.org/p/oMAxxSzAP7F

func IsString

func IsString(any interface{}) (isStrings bool, str string)

Examples : https://play.golang.org/p/9XUt9Jf11WG | https://play.golang.org/p/oMAxxSzAP7F

func IsStringOrStringPointer

func IsStringOrStringPointer(any interface{}) (isString bool, stringPointer *string)

Examples : https://play.golang.org/p/9XUt9Jf11WG | https://play.golang.org/p/oMAxxSzAP7F

func IsStringsOrStringsPointer

func IsStringsOrStringsPointer(any interface{}) (isStrings bool, stringsPtr *[]string)

Examples : https://play.golang.org/p/9XUt9Jf11WG | https://play.golang.org/p/oMAxxSzAP7F

func IsType

func IsType(any interface{}, typeName string) bool

func IsTypeSame

func IsTypeSame(type1 reflect.Type, type2 reflect.Type) bool

Types

type PointerInfo

type PointerInfo struct {
	IsPointer    bool
	ReflectValue reflect.Value
	Pointer      *uintptr
}

func GetPointerInfo

func GetPointerInfo(any interface{}) PointerInfo

type ScanReport

type ScanReport struct {
	ReflectionValue         *reflect.Value
	IndirectReflectionValue *reflect.Value
	ReflectionType          reflect.Type
	IndirectReflectionType  *reflect.Type
	VisitedTypes            *[]reflect.Type
	FinalDeductedType       reflect.Type
	IsPointer               bool
	IsInterface             bool
	IsInt                   bool
	IsBool                  bool
	IsByte                  bool
	IsString                bool
	IsSlice                 bool
	IsMap                   bool
	IsFunc                  bool
	IsArray                 bool
	TypeName                string
}

func NewScanReport

func NewScanReport(any interface{}, maxTries int) ScanReport

Example : https://play.golang.org/p/lHol_zbu4Pn

Jump to

Keyboard shortcuts

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