Phase 3Days 11-15

Structs, Methods, Interfaces & Generics

Go’s composition-first type system and explicit error design

Phase Goal

Design small, testable APIs using composition, narrow interfaces, errors, and restrained generics.

Progress

Day 11: Structs, Composition & Invariants

Day 12: Methods & Receiver Decisions

Day 13: Interfaces & Dependency Inversion

Day 14: Errors, Wrapping, Panic & Recovery

Day 15: Mini Project — Multi-Source Habitat Importer

Capstone
Multi-Source Habitat Importer

Build a CLI that imports ranger CSV, JSON sensor dumps, and hand-entered text observations through a narrow source interface into one validated habitat record model.

  • Consumer-owned source interface
  • Wrapped errors that preserve file and row context
  • A new source format added without changing orchestration

Phase Complete!

After this phase, you'll be able to:

  • Struct literals, field visibility, and zero-value design
  • Embedding versus inheritance
  • Constructors as ordinary functions
  • Validation boundaries and invariant ownership
  • Method sets and receiver syntax
  • Value versus pointer receiver decision rules
  • Mutation, copying, and consistency
  • Fluent APIs and why hidden mutation surprises

You can apply Phase 3 skills in a finished, explainable Go project.