Compare commits

...

1 Commits

Author SHA1 Message Date
Thomas Pelletier 942841787a Fix reflect.Pointer backward compatibility (#813)
Though we don't officially support older versions of Go, this is an easy fix to
unblock people.

Fixes #812
2022-08-26 09:15:03 -04:00
+2 -2
View File
@@ -1140,7 +1140,7 @@ func fieldByIndex(v reflect.Value, path []int) reflect.Value {
for i, x := range path { for i, x := range path {
v = v.Field(x) 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() { if v.IsNil() {
v.Set(reflect.New(v.Type().Elem())) 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 == "" { if f.Anonymous && name == "" {
t2 := f.Type t2 := f.Type
if t2.Kind() == reflect.Pointer { if t2.Kind() == reflect.Ptr {
t2 = t2.Elem() t2 = t2.Elem()
} }