go
module_error
ai_generated
true
go: module github.com/example/mod: not found in workspace
ID: go/dependency-not-found-in-workspace
80%Fix Rate
86%Confidence
0Evidence
2025-05-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.18 | active | — | — | — |
| 1.21 | active | — | — | — |
| 1.22 | active | — | — | — |
Root Cause
When using Go workspaces (go.work), a required module is not listed in the workspace's go.work file.
generic中文
使用 Go 工作区 (go.work) 时,必需模块未列在工作区的 go.work 文件中。
Workarounds
-
95% success 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% success Initialize a new workspace with all modules.
Run 'go work init' followed by 'go work use ./module1 ./module2' to add all modules.
Dead Ends
Common approaches that don't work:
-
Adding the module path to go.mod instead of go.work.
90% fail
go.work is separate from go.mod; the workspace must include the module.
-
Removing go.work and running without workspace.
50% fail
This may break other modules that depend on the workspace structure.