From 64c88c49bbca337b7d76e2734cee6fc84fc88f8d Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Fri, 26 Aug 2022 08:58:43 -0400 Subject: [PATCH] Fix reflect.Pointer backward compatibility Though we don't officially support older versions of Go, this is an easy fix to unblock people. Fixes #812 --- unmarshaler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unmarshaler.go b/unmarshaler.go index 31339cf3..d0d7a72d 100644 --- a/unmarshaler.go +++ b/unmarshaler.go @@ -1140,7 +1140,7 @@ func fieldByIndex(v reflect.Value, path []int) reflect.Value { for i, x := range path { v = v.Field(x) - if i < len(path)-1 && v.Kind() == reflect.Pointer { + if i < len(path)-1 && v.Kind() == reflect.Ptr { if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } @@ -1208,7 +1208,7 @@ func forEachField(t reflect.Type, path []int, do func(name string, path []int)) if f.Anonymous && name == "" { t2 := f.Type - if t2.Kind() == reflect.Pointer { + if t2.Kind() == reflect.Ptr { t2 = t2.Elem() }