Documentation
¶
Overview ¶
Package rivertags decodes a struct type into river object and structural tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { Name []string // Name of tagged field Index []int // Index into field (reflect.Value.FieldByIndex) Flags Flags // Flags assigned to field }
Field is a tagged field within a struct.
func Get ¶
Get returns the list of tagged fields for some struct type ty. Get panics if ty is not a struct type.
Get examines each tagged field in ty for a river key. The river key is then parsed as containing a name for the field, followed by a required comma-separated list of options. The name may be empty for fields which do not require a name. Get will ignore any field that is not tagged with a river key.
Get will treat anonymous struct fields as if the inner fields were fields in the outer struct.
Examples of struct field tags and their meanings:
// Field is used as a required block named "my_block". Field struct{} `river:"my_block,block"` // Field is used as an optional block named "my_block". Field struct{} `river:"my_block,block,optional"` // Field is used as a required attribute named "my_attr". Field string `river:"my_attr,attr"` // Field is used as an optional attribute named "my_attr". Field string `river:"my_attr,attr,optional"` // Field is used for storing the label of the block which the struct // represents. Field string `river:",label"`
With the exception of the `river:",label"` tag, all tagged fields must have a unique name.
The type of tagged fields may be any Go type, with the exception of `river:",label"` tags, which must be strings.
func (Field) IsOptional ¶
IsOptional returns whether f is optional.
type Flags ¶
type Flags uint
Flags is a bitmap of flags associated with a field on a struct.