From 484db0ce59c3343d45b10961618a9ee3cefb89e4 Mon Sep 17 00:00:00 2001 From: Dmitrii Aleksandrov Date: Fri, 11 Oct 2024 11:36:18 +0300 Subject: [PATCH] field: get: use reflect.NewAt in default case Signed-off-by: Dmitrii Aleksandrov --- field.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/field.go b/field.go index f3ef7a3..6cb6573 100644 --- a/field.go +++ b/field.go @@ -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 { @@ -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() } } }