Go-चे कोणतेही inheritance नाही — त्याऐवजी हे struct embedding द्वारे composition वापरते. एक struct (किंवा interface) दुसरे struct-मध्ये embed करून, बाहेरील type ला आंतरिक type-चे fields आणि methods थेट मिळतात. Go-चा हा code reuse-चा जवाब आहे, जो "is-a" inheritance-पेक्षा "has-a" composition-ला प्राधान्य देते.
Struct embedding
Animal {
Name
}
Eat() {
a.Name +
}
Dog {
Animal
Breed
}
d := Dog{
Animal: Animal{Name: },
Breed: ,
}
fmt.Println(d.Name)
fmt.Println(d.Eat())
