Hi all! I've encountered a limitation and I'd like to understand what's going on and why it's not working the way I would expect.
If I have a slice of an interface type, and another slice of a type that implements that interface, I cannot concat these slices together using append - but I can add each item one by one. I would expect that interface implementations would also apply to slices, but it looks like it doesn't? Here's the brief example: https://go.dev/play/p/sWFKeVfSOkW package main type IExample interface { Foo() string } type TBar struct{} func (t TBar) Foo() string { return "" } func main() { examples := []IExample{} bars := []TBar{TBar{}, TBar{}} // Works for _, bar := range bars { examples = append(examples, bar) } // Does not work examples = append(examples, bars...) // ./prog.go:23:30: cannot use bars (variable of type []TBar) as []IExample value in argument to append } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f2da2d69-42b2-475b-8a4d-eb653b2d134bn%40googlegroups.com.