# 错误：打开 /path/file：没有那个文件或目录

- **ID:** `go/os-file-not-found-with-permission-denied`
- **领域:** go
- **类别:** io_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

尝试打开指定路径下不存在的文件，可能由于拼写错误或缺少目录。

## 版本兼容性

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

## 解决方案

1. **Check file existence before opening and use filepath.Join for path construction** (95% 成功率)
   ```
   if _, err := os.Stat(filepath.Join(dir, filename)); os.IsNotExist(err) { return err }
f, err := os.Open(filepath.Join(dir, filename))
   ```

## 无效尝试

- **Using absolute path incorrectly** — Hardcoding absolute paths breaks portability; relative paths may work. (60% 失败率)
