by cjslep · 7y ago · 0 comments
"When writing generic Go, only accept `interface{}` and never a slice" is a painful maxim but works.
Yet another reason to just use `interface{}`: if the caller already has a value of type `[]Concrete` then they can just pass it in directly; otherwise the caller will need to allocate and copy the value's elements into a new value of `[]interface{}` type since the `[]Concrete` is not castable: https://play.golang.org/p/whh1mAAlN-N