MCPcopy Create free account
hub / github.com/featureform/featureform / NewStructIterator

Function NewStructIterator

helpers/struct_iterator/struct_iterator.go:60–72  ·  view source on GitHub ↗

NewStructIterator creates returns a new iterator for a struct. This only works with struct types, not maps. It will only iterate over public members of the struct. Currently struct pointers will result in an error

(s interface{})

Source from the content-addressed store, hash-verified

58// over public members of the struct. Currently struct pointers will
59// result in an error
60func NewStructIterator(s interface{}) (*StructIterator, error) {
61 t := reflect.TypeOf(s).Kind()
62 if t != reflect.Struct {
63 return nil, fmt.Errorf("cannot create iterator from type %T", s)
64 }
65
66 v := reflect.ValueOf(s)
67 return &StructIterator{
68 idx: -1,
69 numField: v.NumField(),
70 val: v,
71 }, nil
72}

Callers 2

TestNewStructIteratorFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestNewStructIteratorFunction · 0.68