structs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Name

func Name(s interface{}) (string, error)

Name returns the structs type name within it's package. Empty string if not a struct.

func Names

func Names(s interface{}, tag ...string) ([]string, error)

Names returns the struct fields name. Field is ignored with tag `structs:"-"` or tag of your choice. Empty slice if not a struct.

Types

type StructField

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

StructField represents a field.

func Field

func Field(s interface{}, n string) (*StructField, error)

Field returns a field from a struct by name.

func Fields

func Fields(s interface{}, tag ...string) ([]*StructField, error)

Fields returns a list field. Tag argument is optional.

func (*StructField) CanSet

func (s *StructField) CanSet() bool

CanSet reports whether the value can be changed.

func (*StructField) IsZero

func (s *StructField) IsZero() bool

IsZero reports whether a value is a zero value of its kind.

func (*StructField) Kind

func (s *StructField) Kind() reflect.Kind

Kind returns the fields kind.

func (*StructField) Name

func (s *StructField) Name() string

Name returns the field name.

func (*StructField) ReflectField

func (s *StructField) ReflectField() reflect.StructField

ReflectField returns the reflect struct field.

func (*StructField) ReflectValue

func (s *StructField) ReflectValue() reflect.Value

ReflectValue returns the reflect field value.

func (*StructField) Set

func (s *StructField) Set(v interface{}) error

Set sets the field value only if field is exported and can be set.

func (*StructField) Tag

func (s *StructField) Tag(k string) string

Tag returns a field tag value by key or a empty string.

func (*StructField) Value

func (s *StructField) Value() interface{}

Value returns the field value.

Jump to

Keyboard shortcuts

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