I have a function which returns a slice of pointers of some interface. I want to change the type later in the code to the implementation type but nothing works, I still get an invalid type assertion.
Example
func Test(c Parsable)([]*Parsable, error) {
// generate slice by factory method on Parsable inteface and return slice
}
var implParsable ImplParsable
results, err := Test(implParsable)
data := results[0].(ImplParsable) // I tried this in many variations but nothing works
resultSets[0]
is a pointer to an interface, so you need to dereference that pointer to get the interface value, which you can do inline since slice values are addressable.
data := (*resultSets[0]).(ImplParsable)