From 6ee36021288e6da67f28118d781b522cfa00a7e9 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Thu, 2 Jun 2022 02:09:47 -0700 Subject: [PATCH] Fix reflectutils.Convert() for maps and []any --- internal/reflectutil/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/reflectutil/utils.go b/internal/reflectutil/utils.go index 61f478f..496b646 100644 --- a/internal/reflectutil/utils.go +++ b/internal/reflectutil/utils.go @@ -104,12 +104,14 @@ func Convert(in reflect.Value, toType reflect.Type) (reflect.Value, error) { err := mapstructure.Decode(in.Interface(), to.Addr().Interface()) if err == nil { return to, nil + } else { + return reflect.Value{}, err } } // If input is a slice of any, and output is an array or slice if in.Type() == reflect.TypeOf([]any{}) && - to.Kind() == reflect.Slice || to.Kind() == reflect.Array { + (to.Kind() == reflect.Slice || to.Kind() == reflect.Array) { // Use ConvertSlice to convert value return reflect.ValueOf(ConvertSlice( in.Interface().([]any),