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.
A Go workspace lets you treat several separate projects as one big project. It is like putting multiple folders into a single folder so you can build or test them all at once. You use this when working on multiple related tools or libraries that depend on each other.