# go: github.com/foo/bar@v1.2.3: 解析 go.mod 出错：
	模块声明的路径为: github.com/foo/baz
	        但被引用为: github.com/foo/bar

- **ID:** `go/module-declares-path-but-required-as`
- **领域:** go
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

模块的 go.mod 声明的模块路径与使用的导入路径不同。常见于仓库重命名/派生后未更新 go.mod。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   go mod edit -replace=github.com/foo/bar=github.com/foo/baz@v1.2.3
go mod tidy
   ```
2. **** (85% 成功率)
   ```
   // in your fork's go.mod
module github.com/you/bar
// then: go mod edit -replace=github.com/foo/bar=github.com/you/bar@v0.0.0-<pseudo>
   ```

## 无效尝试

- **** — go.sum does not encode module path mapping; the error persists (95% 失败率)
- **** — GOPRIVATE only affects proxy/checksum behavior, not path validation (85% 失败率)
- **** — the source at that path may not exist or may be a different module (60% 失败率)
