Generate 'go.work' for a project
Generate 'go.work' by using the context menu or a quick-fix with 'replace' directives
Right-click the root folder of your project and navigate to New | Go Workspace File. When you select it, a go.work file will appear in your root folder. Existing Go modules will automatically be added to the go.work file.
Also, you can generate go.work from go.mod if you have replace directives there. Place the caret on a replace directive, press ⌥⏎ (macOS) / Alt+Enter (Windows/Linux) to see all available intention actions, and select the Generate ‘go.work’ using ‘replace’ directives quick-fix.