Changelog Master Feed

The files & folders of Go projects (Go Time #278)

May 31, 2023
Ask episode
AI Snips
Chapters
Transcript
Episode notes
INSIGHT

No Circular Imports Forces Better Architecture

  • Go’s no-circular-dependencies rule strongly shapes package layout and encourages dependency flow in one direction.
  • Ben Johnson recommends placing domain objects in the root so other packages depend on domain interfaces rather than each other.
ADVICE

Start Single Then Split When Needed

  • Start with a single package for apps and split packages only when clear boundaries emerge.
  • Chris Brando and Ben both advise merging packages instead of creating many tiny ones to avoid future refactor pain.
ADVICE

Split Large Files Without Splitting Types

  • Break very large files into meaningful units but keep related types and methods together in one file.
  • Chris James suggests simple PartOne.go/PartTwo.go splits; avoid splitting a single type across files to reduce cognitive load.
Get the Snipd Podcast app to discover more snips from this episode
Get the app