xreflect

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToMap

func AnyToMap(value interface{}, opts ...StructOption) (map[string]any, error)

将value 转换为map

func GetBool

func GetBool(tmp interface{}) bool

func GetFloat64

func GetFloat64(tmp interface{}) (float64, error)

func GetInt

func GetInt(tmp interface{}) (int, error)

func GetInt64

func GetInt64(tmp interface{}) (int64, error)

func GetRealReflectVal added in v0.2.2

func GetRealReflectVal(f *field, v reflect.Value) (subv reflect.Value)

func GetString

func GetString(v interface{}) string

func GetUint64

func GetUint64(tmp interface{}) (uint64, error)

Types

type MapScanner

type MapScanner interface {
	MapScan(val any) error
}

type StructFields

type StructFields struct {
	List      []field
	ExactName map[string]*field
	// contains filtered or unexported fields
}

func CachedTypeFields

func CachedTypeFields(t reflect.Type) *StructFields

func (*StructFields) Dencode added in v0.2.3

func (f *StructFields) Dencode(rv reflect.Value, name string, val any) (err error)

反序列化结构体的对应属性

type StructOption

type StructOption func(*structOptions)

func WithMaxDepth

func WithMaxDepth(maxDepth int) StructOption

type StructScanner

type StructScanner interface {
	StructScan(vals ...any) error
}

type TagOptions added in v0.3.0

type TagOptions string

tagOptions is the string following a comma in a struct field's "json" tag, or the empty string. It does not include the leading comma.

func (TagOptions) Contains added in v0.3.0

func (o TagOptions) Contains(optionName string) bool

Contains reports whether a comma-separated list of options contains a particular substr flag. substr must be surrounded by a string boundary or commas.

func (TagOptions) GetArgsInfo added in v0.3.0

func (o TagOptions) GetArgsInfo(opt string) (args []string, ok bool)

Jump to

Keyboard shortcuts

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