index := append(traversal.IndexPrefix, field.Index...)
Is not creating unique index path copies. It happens to be when the capacity of the slice is 1 or 2 and adding one more, but not once you get to 3, where the capacity doubles again to 4. This means append() will quit making copies at that point, and subsequently assigned fields at this level will all point to the last entry.
You can reproduce this by creating a struct like
type Level1 struct {
Level2
}
type Level2 struct {
Level3
}
type Level3 struct {
Level4
}
type Level4 struct {
One string
Two string
Three string
Four string
}
The field path index build with
Is not creating unique index path copies. It happens to be when the capacity of the slice is 1 or 2 and adding one more, but not once you get to 3, where the capacity doubles again to 4. This means append() will quit making copies at that point, and subsequently assigned fields at this level will all point to the last entry.
You can reproduce this by creating a struct like
The resulting map will have