I have a method in Golang that requires a []*type as a parameter.
I have a slice:
s := make([]myType, 3)
How do I do that?
I have a method in Golang that requires a []*type as a parameter.
I have a slice:
s := make([]myType, 3)
How do I do that?
In short (and as somewhat alluded to by other commenters), it sounds like you're asking how to use a feature that Go doesn't support. Namely, generics: a function with signature []*type
, where type
isn't actually a specific concrete type that you've already defined. While this might be supported in the future, it isn't for right now - you're stuck with defining the function with []*specific-concrete-type
for now.