CompositionStruct Embedding & Composition
All courses

Composition over inheritance

Embedded fields promote methods to the outer struct. Go has no class inheritance — embedding is composition with syntactic sugar.

Best practice: Embed for "has-a" relationships and interface reuse, not for deep hierarchies.

Output
Press Run to execute your code.