Go Tutorial - Learn Go from the Basics with Code Examples on golangbot.com · Mar 23, 2026
Composition Instead of Inheritance - OOP in Go
0Sign in to vote or save
This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.
Welcome to tutorial no. 27 in Golang tutorial series. Go does not support inheritance, however, it does support composition. The generic definition of composition is “put together”. One example of composition is a car. A car is composed of wheels, an engine and various other parts. Composition by embedding structs Composition can be achieved in Go is by embedding one struct type into…
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.