# go: 解析 go.mod 失败：意外的模块路径 "example.com/foo"

- **ID:** `go/go-mod-replace-directive-error`
- **领域:** go
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

go.mod 文件存在语法错误，通常在 replace 指令中模块路径未正确引用或格式错误。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Check the go.mod file for any misplaced characters or newlines; use 'go mod edit -fmt' to format it correctly.
   ```
2. **** (85% 成功率)
   ```
   If the error is in a replace directive, ensure the syntax is 'replace module => replacement' with correct paths.
   ```

## 无效尝试

- **** — Module paths in go.mod are not quoted; adding quotes will cause a different parsing error. (80% 失败率)
- **** — This may break builds if the replace was needed for local development. (40% 失败率)
