Skip to content

Commit

Permalink
Fix array lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamNHarvey committed Jul 19, 2023
1 parent 023bedd commit fb2d1a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion model.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ func (m *Model) fieldByName(s string) (reflect.Value, error) {
}

func (m *Model) tagForFieldByName(fieldName string, tagName string) (string, error) {
fbn, ok := reflect.TypeOf(m.Value).Elem().FieldByName(fieldName)
el := reflect.TypeOf(m.Value).Elem()
if el.Kind() != reflect.Struct {
return "", fmt.Errorf("model is not a struct")
}
fbn, ok := el.FieldByName(fieldName)
if !ok {
return "", fmt.Errorf("model does not have a field named %s", fieldName)
}
Expand Down

0 comments on commit fb2d1a8

Please sign in to comment.