go
module_error
ai_generated
true
go: 在工作区中未找到模块
go: module github.com/example/mod: not found in workspace
ID: go/dependency-not-found-in-workspace
80%修复率
86%置信度
0证据数
2025-05-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.18 | active | — | — | — |
| 1.21 | active | — | — | — |
| 1.22 | active | — | — | — |
根因分析
使用 Go 工作区 (go.work) 时,必需模块未列在工作区的 go.work 文件中。
English
When using Go workspaces (go.work), a required module is not listed in the workspace's go.work file.
解决方案
-
95% 成功率 Add the module to the workspace's go.work file.
Run 'go work use ./path/to/module' to include the module in the workspace.
-
90% 成功率 Initialize a new workspace with all modules.
Run 'go work init' followed by 'go work use ./module1 ./module2' to add all modules.
无效尝试
常见但无效的做法:
-
Adding the module path to go.mod instead of go.work.
90% 失败
go.work is separate from go.mod; the workspace must include the module.
-
Removing go.work and running without workspace.
50% 失败
This may break other modules that depend on the workspace structure.