Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StructIter ¶
type StructIter struct {
// contains filtered or unexported fields
}
StructIter is an iterator for ranging over a struct's fields with their values
func NewStructIter ¶
func NewStructIter(val reflect.Value) *StructIter
NewStructIter returns a new instance of StructIter for the specified value. It returns nil if v's Kind is not Struct.
func StructRange ¶
func StructRange(v interface{}) *StructIter
StructRange returns a range iterator for a struct value. It returns nil if v's Kind is not Struct.
Call Next to advance the iterator, and Field/Value to access each entry. Next returns false when the iterator is exhausted. StructRange follows the same iteration semantics as a range statement.
Example:
s := struct{
...
}{
...
}
iter := unstructured.StructRange(s)
for iter.Next() {
f := iter.Field()
v := iter.Value()
...
}
func (StructIter) Field ¶
func (it StructIter) Field() reflect.StructField
Field returns the struct field of the iterator's current entry.
func (*StructIter) Next ¶
func (it *StructIter) Next() bool
Next advances the iterator and reports whether there is another entry. It returns false when the iterator is exhausted; subsequent calls will panic.
func (StructIter) Value ¶
func (it StructIter) Value() reflect.Value
Value returns the value of the iterator's current entry.