# panic: time: Reset called on timer with negative duration

- **ID:** `go/panic-timer-reset-negative-duration`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Calling Timer.Reset() with a negative duration value causes a runtime panic in Go's time package.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Go 1.15 | active | — | — |
| Go 1.16 | active | — | — |
| Go 1.17 | active | — | — |
| Go 1.18 | active | — | — |
| Go 1.19 | active | — | — |
| Go 1.20 | active | — | — |
| Go 1.21 | active | — | — |
| Go 1.22 | active | — | — |
| Go 1.23 | active | — | — |

## Workarounds

1. **Use time.Duration(math.Abs(float64(d))) to ensure non-negative duration before calling Reset()** (95% success)
   ```
   Use time.Duration(math.Abs(float64(d))) to ensure non-negative duration before calling Reset()
   ```
2. **Check duration with if d < 0 { d = 0 } before timer.Reset(d)** (90% success)
   ```
   Check duration with if d < 0 { d = 0 } before timer.Reset(d)
   ```
3. **Use time.NewTimer() with a positive duration and stop it explicitly instead of resetting** (85% success)
   ```
   Use time.NewTimer() with a positive duration and stop it explicitly instead of resetting
   ```

## Dead Ends

- **** — time.Duration() does not validate sign; negative values remain negative. (80% fail)
- **** — time.AfterFunc() also panics on negative duration; same underlying issue. (90% fail)
- **** — Panic recovery masks the bug but timer state is corrupted; leads to unpredictable behavior. (75% fail)
