I'm trying to achieve something as below.
package main
import (
"fmt"
)
type MyStruct struct {
Value int
}
func main() {
x := []MyStruct{
MyStruct{
Value : 5,
},
MyStruct{
Value : 6,
},
}
var y []interface{}
y = x // This throws a compile time error
_,_ = x,y
}
This gives a compile time error:
sample.go:21: cannot use x (type []MyStruct) as type []interface {} in assignment
Why is this not possible?.If not is there any other way to hold generic object arrays in Golang?