In runtime internal, blank and non-blank interface types are represented with different structures. https://go101.org/article/value-part.html#interface-structure mentions this a little.
On Tuesday, January 22, 2019 at 1:38:23 PM UTC-4, 徐建海 wrote: > > when i dig ingo value.go, i found that: > func (v Value) Elem() Value { > k := v.kind() > switch k { > case Interface: > var eface interface{} > if v.typ.NumMethod() == 0 { > eface = *(*interface{})(v.ptr) > } else { > eface = (interface{})(*(*interface { > M() > })(v.ptr)) > } > x := unpackEface(eface) > if x.flag != 0 { > x.flag |= v.flag.ro() > } > return x > case Ptr: > ptr := v.ptr > if v.flag&flagIndir != 0 { > ptr = *(*unsafe.Pointer)(ptr) > } > // The returned value's address is v's value. > if ptr == nil { > return Value{} > } > tt := (*ptrType)(unsafe.Pointer(v.typ)) > typ := tt.elem > fl := v.flag&flagRO | flagIndir | flagAddr > fl |= flag(typ.Kind()) > return Value{typ, ptr, fl} > } > panic(&ValueError{"reflect.Value.Elem", v.kind()}) > } > I am curious about one piece of it: > eface = (interface{})(*(*interface { > M() > })(v.ptr)) > > the M() mean nothing? just show that v.ptr is not eface? > > -- 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. For more options, visit https://groups.google.com/d/optout.