diff --git a/util/gconv/gconv_struct.go b/util/gconv/gconv_struct.go index 5e39805a5..e7020ee45 100644 --- a/util/gconv/gconv_struct.go +++ b/util/gconv/gconv_struct.go @@ -61,12 +61,6 @@ func doStruct(params interface{}, pointer interface{}, recursive bool, mapping . } }() - // paramsMap is the map[string]interface{} type variable for params. - paramsMap := MapDeep(params) - if paramsMap == nil { - return gerror.Newf("invalid params: %v", params) - } - // UnmarshalValue. // Assign value with interface UnmarshalValue. // Note that only pointer can implement interface UnmarshalValue. @@ -74,6 +68,12 @@ func doStruct(params interface{}, pointer interface{}, recursive bool, mapping . return v.UnmarshalValue(params) } + // paramsMap is the map[string]interface{} type variable for params. + paramsMap := MapDeep(params) + if paramsMap == nil { + return gerror.Newf("invalid params: %v", params) + } + // Using reflect to do the converting, // it also supports type of reflect.Value for (always in internal usage). elem, ok := pointer.(reflect.Value)