Go CLI Modules and Workspaces/Add module to workspace

Add one or more modules to go.work.

Section: Workspaces

Add module to workspace

bash
bash
go work use ./app ./lib
Explanation

Add one or more modules to go.work. Useful in Go CLI workflows.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Workspaces
Initialize workspace
Create a go.work file for multiple local modules.
OpenIn sheetbashsame section
Recursively add modules
Add modules under a tree recursively.
OpenIn sheetbashsame section
Print go.work JSON
Inspect go.work configuration as JSON.
OpenIn sheetbashsame section
Sync workspace build list
Sync workspace dependencies back to module go.mod files.
OpenIn sheetbashsame section
Initialize module
Create a new go.mod for the current project.
OpenIn sheetbash1 tag match
Add replace directive
Point a module dependency to a local checkout.
OpenIn sheetbash1 tag match