Go does not have inheritance. Composition is used in order to embed items (mostly structs) in one another. This is convenient when you have a baseline struct that is used for many different functions, with other structs that build on top of the initial struct.
We can describe some of the items in my kitchen to show how inheritance works.
We can initialize our program as shown in the following code block. In this block, we create two structs:
Utensils: For the utensils I have in my drawers in my kitchen
Appliances: For the appliances I have in my kitchen
package main
import "fmt"
func main() {
type Utensils struct {
fork string
spoon string
knife string
}
type Appliances struct {
stove string
dishwasher string
oven string
}
I can next use Go's nested structuring to create a Kitchen...