xreflect

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 3 Imported by: 4

README

xreflect

Dependencies

  • xtesting*

Documents

Types
  • type Smpflag int8
  • type Smpval struct
  • type Smplen struct
Variables
  • None
Constants
  • const Int Smpflag
  • const Uint Smpflag
  • const Float Smpflag
  • const Complex Smpflag
  • const Bool Smpflag
  • const String Smpflag
Functions
  • func GetUnexportedField(field reflect.Value) interface{}
  • func SetUnexportedField(field reflect.Value, value interface{})
  • func IsEmptyValue(i interface{}) bool
  • func GetInt(i interface{}) (int64, bool)
  • func GetUint(i interface{}) (uint64, bool)
  • func GetFloat(i interface{}) (float64, bool)
  • func GetComplex(i interface{}) (complex128, bool)
  • func GetBool(i interface{}) (bool, bool)
  • func GetString(i interface{}) (string, bool)
  • func SmpvalOf(i interface{}) *Smpval
  • func SmplenOf(i interface{}) *Smplen
Methods
  • func (i *Smpval) Int() int64
  • func (i *Smpval) Uint() uint64
  • func (i *Smpval) Float() float64
  • func (i *Smpval) Complex() complex128
  • func (i *Smpval) Bool() bool
  • func (i *Smpval) String() string
  • func (i *Smpval) Flag() Smpflag
  • func (i *Smplen) Int() int64
  • func (i *Smplen) Uint() uint64
  • func (i *Smplen) Float() float64
  • func (i *Smplen) Complex() complex128
  • func (i *Smplen) Bool() bool
  • func (i *Smplen) Flag() Smpflag

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBool added in v1.3.3

func GetBool(i interface{}) (bool, bool)

GetBool returns a bool value from bool interface.

func GetComplex added in v1.4.2

func GetComplex(i interface{}) (complex128, bool)

GetComplex returns the complex128 value from complex64, complex128 interface.

func GetFloat added in v1.3.3

func GetFloat(i interface{}) (float64, bool)

GetFloat returns the float64 value from float32, float64 interface.

func GetInt added in v1.3.3

func GetInt(i interface{}) (int64, bool)

GetInt returns the int64 value from int, int8, int32, int64 interface.

func GetString added in v1.3.3

func GetString(i interface{}) (string, bool)

GetString returns a string value from string interface.

func GetUint added in v1.3.3

func GetUint(i interface{}) (uint64, bool)

GetUint returns the uint64 value from uint, uint8, uint16, uint32, uint64, uintptr interface.

func GetUnexportedField added in v1.4.1

func GetUnexportedField(field reflect.Value) interface{}

GetUnexportedField gets the unexported struct field value. Example:

GetUnexportedField(reflect.ValueOf(app).Elem().FieldByName("noMethod")).(gin.HandlersChain)

func IsEmptyValue added in v1.5.0

func IsEmptyValue(i interface{}) bool

IsEmptyValue checks if a value is an empty value, panics when using unsupported type. Only supports:

int, intX, uint, uintX, uintptr, floatX, complexX, bool, string, slice, array, map, interface, pointer.

func SetUnexportedField added in v1.4.1

func SetUnexportedField(field reflect.Value, value interface{})

SetUnexportedField sets value to unexported struct field. Example:

SetUnexportedField(reflect.ValueOf(c).Elem().FieldByName("fullPath"), fullPath)

Types

type Smpflag added in v1.5.0

type Smpflag int8

Smpflag represents Smpval and Smplen flags. Includes: Int, Uint, Float, Complex, Bool, String.

const (
	Int     Smpflag = iota + 1 // For int, int8 (byte), int16, int32 (rune), int64, or length of string, slice, map, array.
	Uint                       // For uint, uint8, uint16, uint32, uint64, uintptr.
	Float                      // For float32, float64.
	Complex                    // For complex64, complex128.
	Bool                       // For bool.
	String                     // For string.
)

type Smplen added in v1.5.0

type Smplen struct {
	// contains filtered or unexported fields
}

Smplen represents the length for some simple types and collection types. Includes:

  1. Int (value): int, int8 (byte), int16, int32 (rune), int64.
  2. Int (length): string, slice, map, array.
  3. Uint (value): uint, uint8, uint16, uint32, uint64, uintptr.
  4. Float (value): float32, float64.
  5. Complex (value): complex64, complex128.
  6. Bool (value): bool

func SmplenOf added in v1.5.0

func SmplenOf(i interface{}) *Smplen

SmplenOf gets the Smplen of given value, panics when using unsupported type. Only supports:

int, intX, uint, uintX, uintptr, floatX, complexX, bool, string, slice, array, map.

func (*Smplen) Bool added in v1.5.0

func (i *Smplen) Bool() bool

Bool returns the bool value of Smplen.

func (*Smplen) Complex added in v1.5.0

func (i *Smplen) Complex() complex128

Complex returns the complex128 value of Smplen.

func (*Smplen) Flag added in v1.5.0

func (i *Smplen) Flag() Smpflag

Flag returns the flag of Smplen.

func (*Smplen) Float added in v1.5.0

func (i *Smplen) Float() float64

Float returns the float64 value of Smplen.

func (*Smplen) Int added in v1.5.0

func (i *Smplen) Int() int64

Int returns the int64 value of Smplen.

func (*Smplen) Uint added in v1.5.0

func (i *Smplen) Uint() uint64

Uint returns the uint64 value of Smplen.

type Smpval added in v1.5.0

type Smpval struct {
	// contains filtered or unexported fields
}

Smpval represents the actual value for some simple types. Includes:

  1. Int: int, int8 (byte), int16, int32 (rune), int64.
  2. Uint: uint, uint8, uint16, uint32, uint64, uintptr.
  3. Float: float32, float64.
  4. Complex: complex64, complex128.
  5. Bool: bool.
  6. String: string.

func SmpvalOf added in v1.5.0

func SmpvalOf(i interface{}) *Smpval

SmpvalOf gets the Smpval from the given value, panics when using unsupported type. Only supports:

int, intX, uint, uintX, uintptr, floatX, complexX, bool, string.

func (*Smpval) Bool added in v1.5.0

func (i *Smpval) Bool() bool

Bool returns the bool value of Smpval.

func (*Smpval) Complex added in v1.5.0

func (i *Smpval) Complex() complex128

Complex returns the complex128 value of Smpval.

func (*Smpval) Flag added in v1.5.0

func (i *Smpval) Flag() Smpflag

Flag returns the flag of Smpval.

func (*Smpval) Float added in v1.5.0

func (i *Smpval) Float() float64

Float returns the float64 value of Smpval.

func (*Smpval) Int added in v1.5.0

func (i *Smpval) Int() int64

Int returns the int64 value of Smpval.

func (*Smpval) String added in v1.5.0

func (i *Smpval) String() string

String returns the string value of Smpval.

func (*Smpval) Uint added in v1.5.0

func (i *Smpval) Uint() uint64

Uint returns the uint64 value of Smpval.

Jump to

Keyboard shortcuts

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