Documentation ¶
Overview ¶
Package reflectx extends the reflect package.
Index ¶
- Variables
- type FieldInfo
- type TypeValueInfo
- func (si TypeValueInfo) AllFields() ([]*FieldInfo, error)
- func (si TypeValueInfo) AllFieldsWithTag(tagName string) ([]*FieldInfo, error)
- func (si TypeValueInfo) AsReturnType() string
- func (si TypeValueInfo) AsReturnValue(name string) string
- func (si TypeValueInfo) CanBeNil() bool
- func (si *TypeValueInfo) TypeInfo() reflect.Type
- func (si TypeValueInfo) TypeName() string
Constants ¶
This section is empty.
Variables ¶
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.