> On 14 Apr 2020, at 09.46, Glen Huang <hey....@gmail.com> wrote: > > With all due respect, I think assigning to interface{} is orthogonal to the > question, which deals with variance. (I asked about it here: > https://groups.google.com/forum/#!topic/golang-nuts/S4p54OpQHGw) > > Here, the type is redefined, so in the context of conversion, it and the > original should be equivalent. > > A tangent question, why this also isn't allowed: > > type Data []byte > type ContainerRaw struct { > Data []byte > } > type Container struct { > Data Data > } > c := Container{[]byte{1}} > ContainerRaw(c) // not allowed, but if Container. Data is of type []byte, > then it's allowed
I think the Go specification can help to provide explanation: https://golang.org/ref/spec#Properties_of_types_and_values -- 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/6303DA91-9A8E-45D3-8B1B-B7D39723D1AC%40gmail.com.