▲ 6 ▼ Code: Golang Pros & Cons (Part 2 of 6): Interface Implementation & Public/Private Designations
Golang Pro: Interface Implementation
Go’s automagic interface implementation is simply amazing. The number one reason we love it is because it saves us from dependency hell.
How Interfaces Work in Golang
Unlike most languages, interfaces in Golang are implemented automatically by structs that match the interface definition. Here’s a simple example. Notice the distinct lack of the implements keyword on the Dog
and Cat
struct.
Register to comment or vote on this story