Empty places in struct slice get filled with reference. This means if an index gets set which is not yet available, all the indices prior to the set one get filled with the same reference to the default struct. Therefore, like shown in the example below, if an index in between gets set, all the other the other inserted index-places will hold the same value.
type easyStruct struct {
a string
}
sl := []easyStruct{}
sl[2] = easyStruct{a: "Hello"}
sl[1].a = "World"
print(sl[0].a) // Results in "World".
This could be solved by either creating a completely new struct for each intermediate index or by just not assigning it at all.
Empty places in struct slice get filled with reference. This means if an index gets set which is not yet available, all the indices prior to the set one get filled with the same reference to the default struct. Therefore, like shown in the example below, if an index in between gets set, all the other the other inserted index-places will hold the same value.
This could be solved by either creating a completely new struct for each intermediate index or by just not assigning it at all.