Interfaces Are Implemented Implicitly
A type implements an interface by implementing its methods. Unlike in many other languages, there is no explicit declaration of intent, there is no "implements" keyword.
Implicit interfaces decouple the definition of an interface from its implementation. You may add methods to a type and in the process be unknowingly implementing various interfaces, and that's okay.
🧠 What the sentence means
“A type implements an interface by implementing its methods.”
That means: If a type (like a struct) has all the methods an interface requires, Go automatically considers it to implement that interface.
You don’t have to declare that it does.
There’s no keyword like implements, extends, or inherits.
🧱 Example in Go
Let's say we have an interface:
type Speaker interface {
Speak() string
}Now, if we define a struct:
type Dog struct{}
func (d Dog) Speak() string {
return "Woof!"
}✅ Because Dog has a method named Speak() with the right signature (string return),
Go automatically knows that Dog satisfies the Speaker interface.
You never had to write:
⚙️ How it’s used
You can now pass a Dog anywhere a Speaker is expected:
✅ Output:
Woof!
🧩 Compare that to other languages
Python
Python uses duck typing — it doesn’t even need an interface declaration.
If it has a .speak() method, you just use it.
So Python’s approach is even looser than Go’s — Go still enforces method signatures and types, but like Python, it’s behavior-based, not inheritance-based.
Java or C#
In Java, you have to explicitly declare that a class implements an interface.
If you forget to write implements Speaker, even though Dog has a speak() method,
Java will not consider it a Speaker.
That’s explicit implementation.
Go skips that ceremony — it’s implicit.
💡 “Implicit Interfaces” — what that means
“Implicit interfaces decouple the definition of an interface from its implementation.”
In plain English:
The person who defines the interface doesn’t have to know about all the types that might implement it.
The person who creates a struct doesn’t have to know about all the interfaces it might satisfy.
They’re decoupled — independent of each other.
You can add a new method to a type, and suddenly it implements an interface you’ve never seen — and that’s fine.
🧩 Example of “unintentionally implementing” an interface
Now Dog implements Logger automatically — even if you didn’t plan for it.
You can pass Dog anywhere a Logger is expected.
That’s what the text means by:
“You may add methods to a type and in the process be unknowingly implementing various interfaces, and that's okay.”
🔍 Why Go does this
Advantages:
Loosely coupled — interfaces don’t depend on struct definitions.
Easy to extend — you can make a new type “fit” an interface just by writing methods.
Encourages behavior-based design (“can it do this?”) rather than inheritance (“what is it?”).
Tradeoff:
You might accidentally satisfy an interface if you name methods the same — but that’s rare in practice and easy to catch via compile-time checks.
🧠 TL;DR — In Your Own Words
Explicit interface (Java)
You must declare “I implement this interface.”
Implicit interface (Go)
If your type has all required methods, you automatically implement it.
Decoupled design
Interfaces and types don’t need to know about each other to work together.
Result
More flexible, reusable, and cleaner code — “less ceremony, same power.”
🧩 Real-world mental model
In Go, you don’t have to ask permission to be part of an interface — you just start acting like it.
If you “walk like a Speaker” (has Speak()),
and “talk like a Speaker” (returns a string),
then Go says:
✅ “Yep, you’re a Speaker.”