A Go workspace lets related modules use one another’s local code during development without giving up independent releases. Each module keeps its own go.mod file and version. This is useful when a change crosses module boundaries but publishing a new version for every iteration would slow the work down. section 11.3 section 11.3.6
Put a go.work file at the repository root and list the modules being developed together. Go then resolves those modules to their local directories instead of downloading their published versions. The workspace changes development-time resolution; users importing a module still receive its published version, not the local code named in go.work. section 11.3.1
go work init ./domain ./storage
From the repository root, run `go work init ./domain ./storage` to create a workspace containing the domain and storage modules. Other modules can be added as they are created. section 11.3.1
Developing an RSS reader across modules
An RSS reader separates its domain model, bbolt storage implementation, REST API, and background worker into four modules. The API and worker can use local domain and storage code before those dependencies have published versions. Changes to a shared interface or storage implementation are available for cross-module testing without tagging a release. section 11.0 section 11.3.4
# Terminal 1: Run worker to fetch feeds cd worker go run ./cmd/worker # Terminal 2: Run API to serve articles cd api go run ./cmd/api # Terminal 3: Query the API curl http://localhost:8080/articles?count=5
Run the worker and API as separate processes, then query the API. This checks the assembled application while both services resolve their shared modules locally. section 11.3.4
Use a workspace when related, independently versioned modules evolve together or need testing before publication. A single-module project needs only package organization; a stable external dependency can remain a versioned requirement in go.mod. A workspace coordinates development rather than replacing module boundaries or releases. section 11.3.6
