chapter eleven

11 Working with Larger Projects

 

Throughout this book, we have built several small applications to demonstrate various parts and patterns of the Go programming language. For the most part, these applications have been self-contained, relying on the standard library packages we explored in previous chapters and custom packages we wrote ourselves. In everyday development, however, this is rarely the case. Developers routinely use shared libraries to support their projects. Unlike the standard library, these external libraries are managed by individuals or small teams rather than undergoing a standardization process requiring community consensus.

Beyond external libraries, applications interact with external services through clients and APIs. Documenting and managing these dependencies can be challenging but is essential in most workflows.

In the chapter on Concurrency, we started an application that used an external dependency to parse RSS feeds. Now, we will build upon that foundation by creating a multi-module architecture that separates concerns and allows different components to evolve independently. We’ll explore packages, modules, and workspaces to keep our code organized and reusable. Specifically, we’ll separate our RSS reader into four modules: a shared domain module (domain model), a storage module (persistent implementation using bbolt), a REST API service, and a background worker that fetches feeds asynchronously.

11.1 Modules

11.1.1 Packages

11.1.2 Domain Module: Shared Domain Model

11.2 Versioning Modules

11.2.1 Storage Module Implementation

11.3 Workspaces

11.3.1 Understanding Workspaces

11.3.2 API Module: REST Service

11.3.3 Worker Module: Background Feed Fetcher

11.3.4 Testing the Complete System

11.3.5 Versioning Independent Modules

11.3.6 Workspace Benefits Demonstrated

11.4 Summary