# 恐慌：时间：对已触发或已停止的计时器调用Reset

- **ID:** `go/goroutine-timer-reset-after-expiry`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

对已过期或已停止的time.Timer调用Reset()，在Go 1.18+中不允许，除非正确排空通道。

## 版本兼容性

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

## 解决方案

1. **Drain timer channel before Reset** (95% 成功率)
   ```
   if !t.Stop() { <-t.C }; t.Reset(duration)
   ```
2. **Use time.NewTimer and avoid Reset** (90% 成功率)
   ```
   t := time.NewTimer(duration); // use once and recreate if needed
   ```

## 无效尝试

- **Using recover() to ignore panic** — Does not fix timer state issue. (90% 失败率)
- **Calling Stop() before Reset() without draining** — Stop() returns false if already fired, but Reset still panics if channel not drained. (85% 失败率)
