field

package
v8.5.9+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name string // the field's original name
	// but if a tag with `name: "other"`
	// exist then this fill is filled, otherwise it's the same as the Name.
	TagName string
	Index   int
	Type    reflect.Type
	Value   reflect.Value
	// contains filtered or unexported fields
}

Field is a controller's field contains all the necessary, internal, information to work with.

func LookupFields

func LookupFields(elem reflect.Type, matcher func(reflect.StructField) bool, handler func(*Field)) (fields []Field)

LookupFields iterates all "elem"'s fields and its fields if structs, recursively. Compares them to the "matcher", if they passed then it executes the "handler" if any, the handler can change the field as it wants to.

It finally returns that collection of the valid fields, can be empty.

func (Field) GetFullName

func (ff Field) GetFullName() string

GetFullName returns the full name of that field i.e: UserController.SessionController.Manager, it's useful for debugging only.

func (Field) GetIndex

func (ff Field) GetIndex() []int

GetIndex returns all the "dimensions" of the controller struct field's position that this field is referring to, recursively. Usage: elem.FieldByIndex(field.getIndex()) for example the {0,1} means that the field is on the second field of the first's field of this struct.

func (Field) GetTagName

func (ff Field) GetTagName() string

GetTagName returns the tag name of the referring field recursively.

func (Field) GetType

func (ff Field) GetType() reflect.Type

GetType returns the type of the referring field, recursively.

func (Field) GetValue

func (ff Field) GetValue() interface{}

GetValue returns a valid value of the referring field, recursively.

func (Field) SendTo

func (ff Field) SendTo(elem reflect.Value)

SendTo should be used when this field or its embedded has a Value on it. It sets the field's value to the "elem" instance, it's the new controller.

Jump to

Keyboard shortcuts

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