---
source: https://iinventedlight.com/library/notes/go-workspaces.md
title: "Go multi-module workspaces (go.work)"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (go.dev text); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Go Authors (go.dev), Tutorial: Getting started with multi-module workspaces - The Go Programming Language, CC BY 4.0 (go.dev text); The Go Authors (go.dev), Go Modules Reference - The Go Programming Language, CC BY 4.0 (go.dev text)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Go"
tags: ['go', 'modules', 'workspaces', 'tooling']
sources:
  - id: S1
    title: "Tutorial: Getting started with multi-module workspaces - The Go Programming Language"
    publisher: The Go Authors (go.dev)
    url: https://go.dev/doc/tutorial/workspaces
    accessed: 2026-11-04
    license: "CC BY 4.0 (go.dev text)"
  - id: S2
    title: "Go Modules Reference - The Go Programming Language"
    publisher: The Go Authors (go.dev)
    url: https://go.dev/ref/mod
    accessed: 2026-11-04
    license: "CC BY 4.0 (go.dev text)"
---
# Go multi-module workspaces (go.work)

**Answer:** A `go.work` file lists the module directories; commands in the workspace treat those modules as main modules, so local changes in one are used by the others.

## Create one

```bash
mkdir ws && cd ws
go work init ./hello
go work use ./example/hello
```

Resulting go.work:

```
go 1.22
use (
    ./hello
    ./example/hello
)
```

## Tips

- `go.work` can also contain `replace` directives that apply to the workspace.
- `go work sync` pushes workspace dependency versions back to each module.

## Claims
- id: C1
  claim: A go.work file specifies a workspace.
  source: S1
  evidence: "In this step, we’ll create a go.work file to specify a workspace with the module."
- id: C2
  claim: go work init creates a go.work file.
  source: S1
  evidence: "The go work init command tells go to create a go.work file"
- id: C3
  claim: A workspace is a collection of modules on disk.
  source: S2
  evidence: "A workspace is a collection of modules on disk that are used as"
- id: C4
  claim: Replace directives can appear in a workspace's go.work file.
  source: S2
  evidence: "or a workspace’s go.work file. A replace directive may apply to a specific"

## Sources
- [S1] Tutorial: Getting started with multi-module workspaces - The Go Programming Language. The Go Authors (go.dev). https://go.dev/doc/tutorial/workspaces . License: CC BY 4.0 (go.dev text). Accessed 2026-11-04.
- [S2] Go Modules Reference - The Go Programming Language. The Go Authors (go.dev). https://go.dev/ref/mod . License: CC BY 4.0 (go.dev text). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
