This question already has an answer here:
- Convert []string to []interface{} 1 answer
- Converting slice of structs to slice of empty interface 1 answer
- Why can't I substitute a slice of one type for another in Go? 3 answers
- Why can't I pass a `func() []int` as `func() []interface{}` in go? 2 answers
- Why a slice []struct doesn't behave same as []builtin? 3 answers
I'm trying to write a function that can take any type (more specifically, trying to get it to take any type of protobuffer, but I'll settle for being more broadly generic if I have to). Based on what I've read, it seems like it can be done like this:
func processSlice(mySlice []interface{}) void{
// Do stuff in here
}
When I try to use this with a slice of protos, though, I get the following error:
cannot use myProtoSlice (type []*MyProto) as type []interface{} in argument to processSlice
</div>