Skip to content
Guest
Go · Course Syllabus Show lessons
Types & Interfaces · 10 min read · Intermediate

Implicit Interfaces & Struct Embedding

Decouple components using Go's small implicit interfaces and compose behavior via struct embedding.

What you'll learn

  • Implement interfaces implicitly without an implements keyword
  • Keep interfaces small (1 to 3 methods)
  • Reuse fields and methods via struct embedding

Overview

Decouple components using Go’s small implicit interfaces and compose behavior via struct embedding.

Go prioritizes simplicity, explicit control flow, fast compilation, and safe concurrency. Every feature in this lesson is part of Go’s minimal standard toolkit used across cloud infrastructure, CLI tools, and high-throughput APIs.

Idiomatic Go Example

package main

import "fmt"

type Notifier interface {
    Send(msg string) string
}

type Email struct{}

func (Email) Send(msg string) string {
    return "Email: " + msg
}

func main() {
    var n Notifier = Email{}
    fmt.Println(n.Send("Welcome"))
}

Key Takeaways

  • Implement interfaces implicitly without an implements keyword
  • Keep interfaces small (1 to 3 methods)
  • Reuse fields and methods via struct embedding

Quick Check

Check Your Understanding

Score: 0 / 1

1. How does a concrete type satisfy an interface in Go?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind