You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#859
sure, To make the TraversalsByNameFunc function in your code case-insensitive, you can modify the fi, ok := tm.Names[name] line to convert the name to lowercase using the strings.ToLower()
you can modify the fi, ok := tm.Names[name] line to convert the name to lowercase using the strings.ToLower() function
tm.Names[strings.ToLower(name)]
This way, the function will find struct fields regardless of the case of their names.
190 lines of a reflectx/reflect.go
func (m *Mapper) TraversalsByNameFunc(t reflect.Type, names []string, fn func(int, []int) error) error {
t = Deref(t)
mustBe(t, reflect.Struct)
tm := m.TypeMap(t)
for i, name := range names {
fi, ok := tm.Names[name]
if !ok {
if err := fn(i, nil); err != nil {
return err
}
} else {
if err := fn(i, fi.Index); err != nil {
return err
}
}
}
return nil
}
The text was updated successfully, but these errors were encountered: