# go: 设置了 -mod=vendor 但 vendor 目录缺失或不完整

- **ID:** `go/vendor-directory-missing`
- **领域:** go
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 vendor 模式时，vendor 目录不存在或缺少必需的依赖项。

## 版本兼容性

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

## 解决方案

1. **Run 'go mod vendor' to populate the vendor directory.** (95% 成功率)
   ```
   Execute 'go mod vendor' in the module root to copy all dependencies.
   ```
2. **Use -mod=mod flag to bypass vendor mode.** (90% 成功率)
   ```
   Build with 'go build -mod=mod' to use module cache instead of vendor.
   ```

## 无效尝试

- **Creating an empty vendor directory manually.** — Go expects the vendor directory to contain all dependencies; empty directory causes build failures. (100% 失败率)
- **Setting GOFLAGS=-mod=mod to ignore vendor.** — This works but doesn't fix the vendor issue; it's a workaround, not a fix. (30% 失败率)
