reflectx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package reflectx extends the reflect package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilPointer = errors.New("reflectx: nil pointer")
	ErrNotStruct  = errors.New("reflectx: not a struct")
)

Errors defined by this package.

Functions

This section is empty.

Types

type FieldInfo

type FieldInfo struct {
	Self  *reflect.StructField
	Value *reflect.Value
}

FieldInfo contains information about a field.

type TypeValueInfo

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

TypeValueInfo contains info about a type and the corresponding value.

func Must

func Must(si *TypeValueInfo, err error) *TypeValueInfo

Must fails if we cannot construct a TypeValueInfo

func NewTypeValueInfo

func NewTypeValueInfo(in interface{}) (*TypeValueInfo, error)

NewTypeValueInfo creates a new TypeValueInfo

func (TypeValueInfo) AllFields

func (si TypeValueInfo) AllFields() ([]*FieldInfo, error)

AllFields returns all fields.

func (TypeValueInfo) AllFieldsWithTag

func (si TypeValueInfo) AllFieldsWithTag(tagName string) ([]*FieldInfo, error)

AllFieldsWithTag returns all fields with a given tag name.

func (TypeValueInfo) AsReturnType

func (si TypeValueInfo) AsReturnType() string

AsReturnType generates a declaration for si as a return type.

func (TypeValueInfo) AsReturnValue

func (si TypeValueInfo) AsReturnValue(name string) string

AsReturnValue generates a declaration for si as a return value.

func (TypeValueInfo) CanBeNil

func (si TypeValueInfo) CanBeNil() bool

CanBeNil returns whether a declaration of this type can be nil.

func (*TypeValueInfo) TypeInfo

func (si *TypeValueInfo) TypeInfo() reflect.Type

TypeInfo returns info about the type

func (TypeValueInfo) TypeName

func (si TypeValueInfo) TypeName() string

TypeName returns the name of the struct type.

Jump to

Keyboard shortcuts

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