diff options
Diffstat (limited to 'vm/type.go')
| -rw-r--r-- | vm/type.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -94,3 +94,13 @@ func StructOf(fields []*Type) *Type { } return &Type{Rtype: reflect.StructOf(rf)} } + +// FieldNameIndex returns the index of struct field name. +func (t *Type) FieldNameIndex(name string) []int { + for _, f := range reflect.VisibleFields(t.Rtype) { + if f.Name == name { + return f.Index + } + } + return nil +} |
