From dc612266ff0a8421200be5f015f0fb4ee1bfe990 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 5 Oct 2023 08:41:50 -0500 Subject: [PATCH] update comment --- field/composite.go | 8 +++++--- message.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/field/composite.go b/field/composite.go index 212975c..6ec6eba 100644 --- a/field/composite.go +++ b/field/composite.go @@ -206,12 +206,14 @@ func (f *Composite) Unmarshal(v interface{}) error { return fmt.Errorf("failed to get data from field %s: %w", indexOrTag, err) } default: // Native types - vv := reflect.New(dataField.Type()).Elem() - err = messageField.Unmarshal(vv) + // using new reflect value that has pointer instead of input data field + dummy := reflect.New(dataField.Type()).Elem() + err = messageField.Unmarshal(dummy) if err != nil { return fmt.Errorf("failed to get data from field %s: %w", indexOrTag, err) } - dataField.Set(vv) + + dataField.Set(dummy) } } diff --git a/message.go b/message.go index e07b472..2823c59 100644 --- a/message.go +++ b/message.go @@ -513,12 +513,14 @@ func (m *Message) Unmarshal(v interface{}) error { return fmt.Errorf("failed to get value from field %d: %w", fieldIndex, err) } default: // Native types - vv := reflect.New(dataField.Type()).Elem() - err = messageField.Unmarshal(vv) + // using new reflect value that has pointer instead of input data field + dummy := reflect.New(dataField.Type()).Elem() + err = messageField.Unmarshal(dummy) if err != nil { return fmt.Errorf("failed to get value from field %d: %w", fieldIndex, err) } - dataField.Set(vv) + + dataField.Set(dummy) } }