# remove /path/to/dir: directory not empty

- **ID:** `go/os-remove-directory-not-empty`
- **Domain:** go
- **Category:** io_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to remove a directory that still contains files or subdirectories using os.Remove() or os.RemoveAll() incorrectly.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.14 | active | — | — |
| 1.15 | active | — | — |
| 1.16 | active | — | — |

## Workarounds

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

## Dead Ends

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