# 包 example.com/foo 不在 GOROOT 中 (/usr/local/go/src/example.com/foo)

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

## 根因

导入路径被错误解析为GOROOT下的标准库，而不是模块依赖。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.16 | active | — | — |
| 1.17 | active | — | — |

## 解决方案

1. **确保在模块目录内运行** (80% 成功率)
   ```
   cd /path/to/module && go build
   ```
2. **设置GO111MODULE=on** (90% 成功率)
   ```
   export GO111MODULE=on
go build
   ```

## 无效尝试

- **复制包到GOROOT目录** — GOROOT不应被修改，且这不是正确做法。 (90% 失败率)
- **设置GO111MODULE=off** — 禁用模块模式会导致其他依赖问题。 (70% 失败率)
