Fix unmarshaling of nested non-exported struct (#917)

Fixes #915
This commit is contained in:
Thomas Pelletier
2023-12-11 14:17:49 -05:00
committed by GitHub
parent 358c8d2c23
commit 34765b4a9e
2 changed files with 25 additions and 3 deletions
+3 -3
View File
@@ -1097,9 +1097,9 @@ func (d *decoder) handleKeyValuePart(key unstable.Iterator, value *unstable.Node
f := fieldByIndex(v, path)
if !f.CanSet() {
// If the field is not settable, need to take a slower path and make a copy of
// the struct itself to a new location.
if !f.CanAddr() {
// If the field is not addressable, need to take a slower path and
// make a copy of the struct itself to a new location.
nvp := reflect.New(v.Type())
nvp.Elem().Set(v)
v = nvp.Elem()