Skip to content

Commit

Permalink
field: get: use reflect.NewAt in default case
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitrii Aleksandrov <goodmobiledevices@gmail.com>
  • Loading branch information
Insei committed Oct 11, 2024
1 parent 3cc8bc1 commit 484db0c
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions field.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,9 @@ func (f *field) Get(obj interface{}) interface{} {
return getPtrValue[*float64](ptrToField)
case reflect.Bool:
return getPtrValue[*bool](ptrToField)
case reflect.Struct:
return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
case reflect.Slice:
return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
case reflect.Array:
return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
default:
panic("unhandled default case")

return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
}
} else {
switch kind {
Expand Down Expand Up @@ -137,14 +132,8 @@ func (f *field) Get(obj interface{}) interface{} {
return getPtrValue[float64](ptrToField)
case reflect.Bool:
return getPtrValue[bool](ptrToField)
case reflect.Struct:
return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
case reflect.Slice:
return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
case reflect.Array:
return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
default:
panic("unhandled default case")
return reflect.NewAt(f.Type, ptrToField).Elem().Interface()
}
}
}
Expand Down

0 comments on commit 484db0c

Please sign in to comment.