# 删除 /path/to/dir: 目录不为空

- **ID:** `go/os-remove-directory-not-empty`
- **领域:** go
- **类别:** io_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 os.Remove() 或 os.RemoveAll() 尝试删除仍然包含文件或子目录的目录。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use os.RemoveAll() for recursive deletion.
   ```
2. **** (90% 成功率)
   ```
   List directory contents and remove files first, then the directory.
   ```

## 无效尝试

- **** — os.RemoveAll() should work, but if it fails, it's due to permission issues or race conditions. (40% 失败率)
- **** — The first call fails, and the second call will also fail. (80% 失败率)
