summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2020-01-24 14:34:56 -0800
committerAlex Flint <[email protected]>2020-01-24 14:34:56 -0800
commit2cc1f136b1375d20aff0ca5429d69af4b0597939 (patch)
tree5a8b7f0a026d063ae3afeaa67d3b2f5d81741a0a /parse.go
parent711618869d25f9f1851bb18d4792c3f46ef9821b (diff)
make sure to deep copy the field indices
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse.go b/parse.go
index 3fc82bd..3370c31 100644
--- a/parse.go
+++ b/parse.go
@@ -159,7 +159,8 @@ func walkFields(t reflect.Type, visit func(field reflect.StructField, owner refl
func walkFieldsImpl(t reflect.Type, visit func(field reflect.StructField, owner reflect.Type) bool, path []int) {
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
- field.Index = append(path, i)
+ field.Index = make([]int, len(path)+1)
+ copy(field.Index, append(path, i))
expand := visit(field, t)
if expand && field.Type.Kind() == reflect.Struct {
var subpath []int