From 92ff95e06a42bd8a6a5d0699899dafaa0034d760 Mon Sep 17 00:00:00 2001 From: tangyuyi Date: Mon, 21 Oct 2024 15:56:44 +0800 Subject: [PATCH] feat: use value returned from Value method as source to copy from Change-Id: I968aee9b89a89f0033ff72ae65b245fbd12c4863 --- copier.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/copier.go b/copier.go index 175ad82..5e920e5 100644 --- a/copier.go +++ b/copier.go @@ -284,6 +284,17 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) dest = indirect(to) } + if source.IsValid() { + if valuer, ok := source.Interface().(driver.Valuer); ok { + value, err := valuer.Value() + if err != nil { + return err + } + source = indirect(reflect.ValueOf(value)) + fromType, _ = indirectType(reflect.TypeOf(value)) + } + } + if len(converters) > 0 { if ok, e := set(dest, source, opt.DeepCopy, converters); e == nil && ok { if isSlice {