reflectutil

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package reflectutil

@author: xwc1125

Package reflectutil

@author: xwc1125

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelPointer

func DelPointer(w interface{}) interface{}

func GetFieldName

func GetFieldName(structName interface{}) []string

GetFieldName structName 的 type 不是结构体类型,就会报以下错误:panic: reflect: NumField of non-struct type,故需要在程序中加以判断。 获取结构体中字段的名称

func GetValue

func GetValue(param interface{}) reflect.Value

func GetValueByFieldName

func GetValueByFieldName(structName interface{}, fieldName string) interface{}

func GetValues

func GetValues(param ...interface{}) []reflect.Value

GetValues 根据参数获取对应的Values

func ReflectInterface

func ReflectInterface(funcInter interface{}, paramsValue []reflect.Value) []reflect.Value

func ToPointer

func ToPointer(w interface{}) interface{}

ToPointer 将 interface{T} 转变为 interface{*T} 如果是指针,直接返回

Types

type FieldInfo

type FieldInfo struct {
	FieldName string // 字段名称
	FieldType string // 字段类型
	TagValue  string // tag的值
}

func GetTagName

func GetTagName(structName interface{}, tagKey string) []FieldInfo

获取结构体中Tag的值,如果没有tag则返回字段值

Jump to

Keyboard shortcuts

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