2 ms·
This is not inheritance, careful about what you say here since it is totally misleading. while embedding structs is useful in a lot of cases, it might yield une
by aikah 11y ago
This is not inheritance, careful about what you say here since it is totally misleading. while embedding structs is useful in a lot of cases, it might yield unexpected results if you expect embedding to work "more like inheritance".
ex
type A struct{}
func (a *A)GetSelf()*A{return a}
type B struct{ A }
b:=&B{A{}}
b.GetSelf() returns type A , not type B
It gets even more confusing when you start embedding interfaces in structs.