How to Use Workspaces in Go (go.work)

Initialize a Go workspace with go work init and add modules using go work use to manage multiple projects together.

Use the go work command to manage multiple modules as a single workspace. Run go work init to create a go.work file, then use go work use to add your module directories.

go work init
go work use ./module-a ./module-b

This allows you to run go build or go test across all included modules simultaneously without modifying individual go.mod files.