Interfaces and Polymorphism

Interfaces and Polymorphism

Interfaces define method sets and enable polymorphism.

type Speaker interface {
    Speak()
}

type Human struct {}

func (h Human) Speak() {
    fmt.Println("Hi")
}
← PrevNext →