liveBook · Manning

Chapter 11: Working with larger projects

What you will learn in chapter 11 of Go in Action, Second Edition

The chapter introduces Go’s packages, modules, versions, and workspaces as tools for turning a small RSS application into an organized multimodule project.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces Go’s packages, modules, versions, and workspaces as tools for turning a small RSS application into an organized multimodule project.

Key terms: packages, modules, go.mod, module versions, workspaces, shared domain module, domain model, storage module, bbolt, REST API service

11.1 Modules

The section sets up a modular RSS reader project and explains how Go’s module files manage dependencies and verify downloaded code.

Key terms: domain, storage, api, worker, modules, go mod init, go.mod, module path, go get, go mod tidy

11.1.1 Packages

This section explains Go package rules and practical directory conventions for organizing a larger, multimodule project.

Key terms: package, main package, main(), circular dependencies, imports, separation of concerns, cmd, pkg, api, web

11.1.2 Domain module: Shared domain model

The section builds a shared domain module for articles and feeds, then uses interfaces and inward-pointing dependencies to keep the API and worker independent of specific infrastructure implementations.

Key terms: domain module, domain-driven design, Article, Feed, Fetcher, Storage, interfaces, Liskov substitution principle, LSP, RSSReader

11.2 Versioning modules

The section versions the domain module and builds a separately versioned bbolt storage adapter that lets the API and worker share article data.

Key terms: semantic versioning, vMAJOR.MINOR.PATCH, domain/v0.0.1, domain.Storage, adapter pattern, ports and adapters, dependency inversion, bbolt, NewBoltStore, readOnly

11.3 Workspaces

Introduces Go workspaces as a way to develop services alongside a shared, versioned domain module without giving up independent modules or releases.

Key terms: Go workspaces, interdependent modules, go.mod, domain module

11.3.1 Understanding workspaces

Explains how a go.work workspace lets independently versioned Go modules use local copies of one another during development.

Key terms: workspace, go.work, local modules, module proxy, go.mod, versioned independently, go-news, domain, storage, api

11.3.2 API module: REST service

The section builds a REST API module that uses shared domain and storage modules, keeps HTTP handlers read-only, tests them in isolation, and wires them to a persistent store.

Key terms: API module, cmd directory pattern, internal directory, storage module, domain.ArticleReader, domain.Storage, BoltStore, RegisterRoutes, mux, Liskov substitution principle

11.3.3 Worker module: Background feed fetcher

This section builds a background RSS worker and shows how it shares domain and storage modules with an independently running API.

Key terms: worker module, API module, domain module, storage module, producer-consumer pattern, workspace, RSSReader, domain.Fetcher, gofeed, port-adapter boundary

11.3.4 Testing the complete system

This section tests the worker and API together, showing how workspace-local modules and shared storage let independent services produce and serve articles.

Key terms: worker, API, JSON response, publication date, feeds, graceful degradation, BoltStore, articles.db, Bbolt, write transactions

11.3.5 Versioning independent modules

This section explains how modules in a multimodule Go project can be released on separate version timelines while communicating compatibility to their users.

Key terms: independent module versioning, Git tag, domain module, API module, worker module, versioning, api/v1.0.0, v1.x releases, logs, monitoring

11.3.6 Workspace benefits demonstrated

This section shows how a Go workspace supports independently versioned modules that evolve together during development, and when that arrangement is worth using.

Key terms: workspace, go.mod, domain model, module versions, domain interfaces, dependency inversion principle, storage, API, worker, workspaces

11.4 Summary

The section recaps how packages, modules, domain boundaries, interfaces, testing, and workspaces help organize and extend a larger Go project.

Concepts explained in this chapter

← Chapter 10: The standard library

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.