s2 := ((*T2)(&t1)).F2() // ok - not expected
works because you throw it on type T2 and that allows F2 . Therefore, it is expected that it will work. Then the function F2 is called on your T2 object t1 , which returns t1.s
s0 := t2.F1() // error - expected ok
For this, I can’t tell you exactly, but only give you my believable idea:
F1 is a method of type T1. Since t2 is not of type T1, you cannot call F1 on t2. So, as you noted, only data fields are separated, not methods of these types.
Also see Go For C ++ Programmers , which says:
Methods are defined for the named types. If you convert the value to another type, the new value will have methods of the new type, not the old one.
source share