|
|
|
|
|
by aikah
4040 days 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 BIt gets even more confusing when you start embedding interfaces in structs. |
|