Closed vishvanath-gojek closed 3 years ago
type slice0 struct { sl1 []slice1 } type slice1 struct { sl2 []slice2 } type slice2 struct { sl2 []int } realdata := slice0{[]slice1{slice1{[]slice2{slice2{[]int{1, 2, 3}}}}}} var copydata slice0 copier.Copy(©data, &realdata) copydata.sl1[0] = slice1{[]slice2{slice2{[]int{10, 20, 30}}}}
Playground example https://play.golang.org/p/drVdfl5hx7M
Running above example results in error index out of range.
index out of range
You are using unexported fields in your example. Copying to unexported field cannot be supported. You should use exported fields. See: https://play.golang.org/p/uIV1Sn8cU9I
Reproducible Example
Playground example https://play.golang.org/p/drVdfl5hx7M
Description
Running above example results in error
index out of range
.