improve function Struct for package gconv

This commit is contained in:
John
2020-07-06 22:37:37 +08:00
parent 7c44bf8e94
commit 0e025eda1b

View File

@ -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()))