Module 04 Β· Interfaces & Errors β Lesson 1 of 3 Β· ~11 min
Interfaces
A contract, not a class
You have structs (Walker, Booking) and methods hanging off them. An interface is the next idea: a named list of method signatures β a contract. Anything that has those methods satisfies the interface, and can be used wherever that interface is expected.
In Swift you'd write a protocol and then say struct Walker: Pricer. Go is different in one big way, and it's the thing to internalize this lesson: there is no implements keyword. You never declare that a type satisfies an interface. If the type has the methods, it satisfies it β automatically, silently, everywhere.
This is called structural or implicit satisfaction. The interface describes a shape; any type of that shape fits.