Back to course

Interfaces: The Power of Polymorphism

Go (Golang) for Cloud-Native Microservices

Interfaces in Go

Interfaces define a set of methods. If a struct implements those methods, it implicitly satisfies the interface. No implements keyword required!

go type Greeter interface { Greet() string }

This is the secret to Go's flexibility. It allows us to swap databases (e.g., SQL for In-memory) without changing the main business logic.