Go CLI Modules and Workspaces/Recursively add modules

Add modules under a tree recursively.

Section: Workspaces

Recursively add modules

bash
bash
go work use -r .
Explanation

Add modules under a tree recursively. 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
Add module to workspace
Add one or more modules to go.work.
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