reflectutil

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: BSD-3-Clause Imports: 4 Imported by: 1

README

reflectutil

reflectutil is a Go package that provides utilities for working with reflection in Go. This is a distillation of functions from several codebases, cleaned up, tested, and gathered in one place for easy reuse.

The main thing this package is useful for is parsing struct tags in the common value,key1,key2:value2 syntax, handling annoying things like missing values, repeated keys, spaces and quotes in parameters, etc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

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

func (*Field) Index added in v0.0.3

func (f *Field) Index() []int

func (*Field) Name

func (f *Field) Name() string

func (*Field) Tag

func (f *Field) Tag(name string) *Tag

func (*Field) Tags

func (f *Field) Tags() TagList

func (*Field) Type

func (f *Field) Type() reflect.Type

type FieldList

type FieldList []Field

func (FieldList) Get

func (l FieldList) Get(name string) *Field

func (FieldList) Has

func (l FieldList) Has(name string) bool

func (FieldList) Names

func (l FieldList) Names() []string

func (FieldList) WithTag

func (l FieldList) WithTag(name string) FieldList

func (FieldList) WithTagValue

func (l FieldList) WithTagValue(name, value string) FieldList

func (FieldList) WithoutTag

func (l FieldList) WithoutTag(name string) FieldList

func (FieldList) WithoutTagValue

func (l FieldList) WithoutTagValue(name, value string) FieldList

type Parameter

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

func (*Parameter) Name

func (p *Parameter) Name() string

func (*Parameter) Value

func (p *Parameter) Value() string

type ParameterList

type ParameterList []Parameter

func (ParameterList) Get

func (l ParameterList) Get(name string) *Parameter

func (ParameterList) Has

func (l ParameterList) Has(name string) bool

func (ParameterList) Names

func (l ParameterList) Names() []string

type StructDescription

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

func GetDescription

func GetDescription(input interface{}) (*StructDescription, error)

func GetDescriptionFromReflectType added in v0.0.4

func GetDescriptionFromReflectType(typ reflect.Type) (*StructDescription, error)

func GetDescriptionFromType added in v0.0.2

func GetDescriptionFromType(typ reflect.Type) (*StructDescription, error)

GetDescriptionFromType is deprecated - use GetDescriptionFromReflectType instead

func (*StructDescription) Field

func (s *StructDescription) Field(name string) *Field

func (*StructDescription) Fields

func (s *StructDescription) Fields() FieldList

func (*StructDescription) Name

func (s *StructDescription) Name() string

func (*StructDescription) Type

func (s *StructDescription) Type() reflect.Type

type Tag

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

func ParseTag added in v0.0.4

func ParseTag(name, tagValue string) (*Tag, error)

func (*Tag) Name

func (t *Tag) Name() string

func (*Tag) Parameter

func (t *Tag) Parameter(name string) *Parameter

func (*Tag) Parameters

func (t *Tag) Parameters() ParameterList

func (*Tag) Value

func (t *Tag) Value() string

type TagList

type TagList []Tag

func ParseTagList added in v0.0.4

func ParseTagList(input string) (TagList, error)

func (TagList) Get

func (l TagList) Get(name string) *Tag

func (TagList) Has

func (l TagList) Has(name string) bool

func (TagList) Names

func (l TagList) Names() []string

func (TagList) WithName

func (l TagList) WithName(name string) TagList

Jump to

Keyboard shortcuts

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