# 错误：重命名 /旧路径 /新路径：无效的跨设备链接

- **ID:** `go/os-rename-file-cross-device`
- **领域:** go
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

尝试在不同文件系统或挂载点之间重命名文件，os.Rename不支持此操作。

## 版本兼容性

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

## 解决方案

1. **Implement copy-then-delete strategy with error handling** (90% 成功率)
   ```
   src, _ := os.Open(oldPath)
dst, _ := os.Create(newPath)
io.Copy(dst, src)
src.Close()
dst.Close()
os.Remove(oldPath)
   ```

## 无效尝试

- **Using os.Rename with fallback to copy+delete only on error** — Does not handle atomicity; may leave partial files. (50% 失败率)
