From 0e025eda1be2f801f6dfe924a65389f643fe2495 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 6 Jul 2020 22:37:37 +0800 Subject: [PATCH] improve function Struct for package gconv --- util/gconv/gconv_struct.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/gconv/gconv_struct.go b/util/gconv/gconv_struct.go index ac302b8fc..245b4f6d7 100644 --- a/util/gconv/gconv_struct.go +++ b/util/gconv/gconv_struct.go @@ -277,6 +277,11 @@ func bindVarToReflectValue(structFieldValue reflect.Value, value interface{}) (e // Converting by kind. switch kind { case reflect.Struct: + // UnmarshalValue. + if v, ok := structFieldValue.Addr().Interface().(apiUnmarshalValue); ok { + return v.UnmarshalValue(value) + } + if err := Struct(value, structFieldValue); err != nil { // Note there's reflect conversion mechanism here. structFieldValue.Set(reflect.ValueOf(value).Convert(structFieldValue.Type()))