Inspectopedia
 
2024.3

Migration to Go workspace is possible

Warning
Sanity
New
Last modified: 03 December 2024

Generates 'go.work' files using 'replace' directives.

Go workspaces is a feature introduced in Go 1.18 that allows working simultaneously on several modules.

Workspaces are a modern alternative to 'replace' directives pointing to local directories.

All modules in a workspace have the same set of dependencies, thus making the configuration simpler, more robust, and requiring fewer 'go list' calls to scan the project structure.

The fix for this inspection generates a new 'go.work' file and does not change existing files.

By default, the 'warning' severity is used. If a generated workspace would include Go modules that were not replaced in the original 'go.mod', no warning is shown due to possible side effects caused by migration. But you can still run the fix manually.

For more information about workspaces, refer to Go Modules Reference.

For Go workspaces introduction, refer to Tutorial: Getting started with multi-module workspaces.