01 / 03

How would you structure a large Go monorepo or multi-service repository?

Large Go repositories use either a multi-module layout with independent go.mod per service, or a single module with services under cmd/ and shared code under pkg/ and internal/.

Recommended monorepo structure
Trade-offs
  1. 1

    Single module: simpler tooling, shared internal packages, atomic cross-service changes, but all services always built together

  2. 2

    Multi-module: independent versioning and deployment, cleaner boundaries, but more tooling complexity with workspace files

  3. 3

    Go workspaces (go.work): manage multi-module repos locally without replacing directives

  4. 4

    Use buf for managing protobuf definitions and gRPC code generation across services

  5. 5

    golangci-lint and Makefile or mage for consistent build/lint/test commands across services