Go has no class inheritance. Instead, you embed one struct type inside another, and the outer struct gets the embedded type's fields and methods promoted to it. This gives you inheritance-like extension through composition: the outer type "has a" inner type but can be used as if it had its members directly.
This article shows how embedding works, how to override promoted methods, how name conflicts resolve, and why an embedded type is not a subtype in the object-oriented sense.
To embed, list a type name in a struct without a field name. The type name becomes the field name, and its exported and unexported members are promoted to the outer type.
d.Name is shorthand for d.Animal.Name. In a composite literal you must name the embedded field (Animal: Animal{...}); you cannot set promoted fields directly there.
If the outer type defines a method with the same name, it shadows the promoted one. The embedded method is still reachable through the explicit field path, which is how you "call super".
The last line surprises people from OOP languages. Intro is defined on Animal, so inside it a.Sound() calls Animal.Sound, not Dog.Sound. Go has no virtual dispatch through embedding: the embedded value never knows it lives inside a Dog. If you need polymorphic behaviour, use interfaces.
Method sets follow the receiver types:
T promotes methods with receiver T to the outer S, and methods with receiver *T to *S.*T promotes both sets to S and *S.Embedding *Counter lets several outer values share one inner instance, but the pointer is nil until you set it, and calling a method that touches fields would then panic.
When two embedded types at the same depth provide the same name, the selector is ambiguous and the compiler rejects any use of it. The shallowest depth always wins.
Resolve it by qualifying the selector or by defining Hello on C.
A Dog cannot be passed where an Animal is expected. Embedding promotes members but does not create an "is a" relationship in the type system.
To accept "anything that can do X", define an interface. Because promoted methods count toward a type's method set, Dog satisfies an interface containing Describe automatically.
You can also embed an interface in a struct. This is useful for decorating or partially overriding an implementation, such as wrapping an io.Writer or http.ResponseWriter.
Not in the class-based sense. Go favours composition: embedding promotes members, and interfaces provide polymorphism.
Yes, through the embedded field name, for example d.Animal.Sound().
Yes. Ambiguities at the same depth must be resolved by qualifying the selector.
The field name is the type name, so it is exported when the type name starts with an uppercase letter. Promoted exported members are accessible either way.
Embedding extends a struct with another type's fields and methods through promotion. Shadow a method to override it, call the embedded one explicitly when needed, and remember there is no virtual dispatch and no subtyping. Use interfaces for polymorphism and embedding for reuse.