From e8fe2e44e40a0b8abbb60dc2f77356137fb142dc Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Sat, 17 Jun 2023 02:03:09 +0300 Subject: [PATCH] fix: `panic: reflect.Value.MapIndex: value of type string is not assignable to type` --- type_go_map.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/type_go_map.go b/type_go_map.go index aa7b780..52d76c6 100644 --- a/type_go_map.go +++ b/type_go_map.go @@ -30,6 +30,10 @@ func newGoMapObject(value reflect.Value) *goMapObject { } func (o goMapObject) toKey(name string) reflect.Value { + if reflect.ValueOf(name).CanConvert(o.keyType) { + return reflect.ValueOf(name).Convert(o.keyType) + } + reflectValue, err := stringToReflectValue(name, o.keyType.Kind()) if err != nil { panic(err)