Go: You can't cast an array of a type *B implementing I to an array of a type I

Given that you have type B where *B implemnets I then *B is assignable to I but []*B is not assignable to []I. I incorrectly assumed this is possible because it made sense that it would be because I know that it would work in certain programming languages in a few cases but it turns out to be impossible in a lot of mainstream languages for an actually very simple reason. Since you pass a live mutable reference which will get promoted to []I it would be possible to perform an assignment such as arr[i] = &C{} (where *C implements I). But since this array of type I points to an array of type *B it would add a *C to an array of type *B which is incompatible. This could only work if the array is passed as read-only or as a copy. But go doesn't have a read-only. However, as it turns out there's more behind it. This would also require that the internal representation of *B and I are the same which in go's case is not true. The internal representation is not the same. Thus, in order to pass a []*B to []I you need to create a new array of type []I and copy each element manually. If you assign *B to I it will perform a conversion (that is the compiler inserts stuff to convert the internal representations).

In languages where the internal representation is the same or/and that have the same kind of data structure for any kind of object and you have some sorts of type bounds this would work without copying because you don't need to convert internal representations and the compiler will reject an assignment of some C extends I to the arary. And this does not require a read-only reference because you can safely resize the array or swap elements in the array. Of coures, most languages don't even have read-only concept and objects are usually passed as mutable references (by which I mean you can modify the object through this reference).