# 包 example.com/user/project：在任何位置都找不到包 "example.com/user/project"：
	/usr/local/go/src/example.com/user/project（来自 $GOROOT）
	/home/user/go/src/example.com/user/project（来自 $GOPATH）

- **ID:** `go/cannot-find-package-in-gopath`
- **领域:** go
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

包未位于预期的 GOPATH 或 GOROOT 目录中，通常是因为项目未克隆到正确的 GOPATH 结构中，或者未启用模块。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |
| 1.2 | active | — | — |
| 1.3 | active | — | — |
| 1.4 | active | — | — |
| 1.5 | active | — | — |
| 1.6 | active | — | — |
| 1.7 | active | — | — |
| 1.8 | active | — | — |
| 1.9 | active | — | — |
| 1.10 | active | — | — |
| 1.11 | active | — | — |
| 1.12 | active | — | — |
| 1.13 | active | — | — |
| 1.14 | active | — | — |
| 1.15 | active | — | — |
| 1.16 | active | — | — |

## 解决方案

1. **Enable Go modules and initialize the module** (95% 成功率)
   ```
   GO111MODULE=on go mod init example.com/user/project
   ```
2. **Move the project to the correct GOPATH location** (85% 成功率)
   ```
   mkdir -p $GOPATH/src/example.com/user && mv /current/project $GOPATH/src/example.com/user/project
   ```

## 无效尝试

- **Setting GO111MODULE=off and hoping GOPATH resolves** — Disabling modules forces GOPATH mode, but if the project is not in the correct GOPATH src directory, it still fails. (70% 失败率)
- **Copying the project to GOROOT/src** — GOROOT is for the standard library; placing user projects there is unsupported and can cause conflicts. (90% 失败率)
