# go: 在工作区中未找到模块

- **ID:** `go/dependency-not-found-in-workspace`
- **领域:** go
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 Go 工作区 (go.work) 时，必需模块未列在工作区的 go.work 文件中。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.18 | active | — | — |
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## 解决方案

1. **Add the module to the workspace's go.work file.** (95% 成功率)
   ```
   Run 'go work use ./path/to/module' to include the module in the workspace.
   ```
2. **Initialize a new workspace with all modules.** (90% 成功率)
   ```
   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.** — go.work is separate from go.mod; the workspace must include the module. (90% 失败率)
- **Removing go.work and running without workspace.** — This may break other modules that depend on the workspace structure. (50% 失败率)
