betterreflect

package
v4.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSingleValueExpected = errors.New("expected single value, got slice")

Functions

func ConvertToStringSlice

func ConvertToStringSlice(value interface{}) ([]string, error)

ConvertToStringSlice converts value into string slice using MarshalText implementation or conversion from primitives to string.

func ConvertToUnderlyingType

func ConvertToUnderlyingType(value interface{}) interface{}

ConvertToUnderlyingType takes a value ot custom type T and converts it to it's underlying types. If value is of built-in type, ConvertToUnderlyingType just returns value as provided.

func IsZero

func IsZero(value interface{}) bool

Types

type Struct

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

func NewStruct

func NewStruct(src interface{}) *Struct

func NewStructFromValue

func NewStructFromValue(src reflect.Value) *Struct

func (*Struct) Field

func (s *Struct) Field(i int) reflect.StructField

func (*Struct) IsPrivate

func (s *Struct) IsPrivate(i int) bool

IsPrivate returns is the field private (unexported) or not.

func (*Struct) IsRequired

func (s *Struct) IsRequired(i int, key string) bool

IsRequired returns if given tag has required flag set.

func (*Struct) NumField

func (s *Struct) NumField() int

func (*Struct) Set

func (s *Struct) Set(i int, value interface{}) (err error)

func (*Struct) Tag

func (s *Struct) Tag(i int, key string) string

func (*Struct) TagInfo

func (s *Struct) TagInfo(i int, key string) (string, bool)

func (*Struct) Type

func (s *Struct) Type(i int) reflect.Type

func (*Struct) Value

func (s *Struct) Value(i int) reflect.Value

Jump to

Keyboard shortcuts

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