Skip to content

Commit

Permalink
Fix reflect.Pointer backward compatibility (#813)
Browse files Browse the repository at this point in the history
Though we don't officially support older versions of Go, this is an easy fix to
unblock people.

Fixes #812
  • Loading branch information
pelletier committed Aug 26, 2022
1 parent 28f1efc commit 9428417
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions unmarshaler.go
Expand Up @@ -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()))
}
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 9428417

Please sign in to comment.