diff --git a/ping.go b/ping.go index e1c09ee..86d632c 100644 --- a/ping.go +++ b/ping.go @@ -518,6 +518,16 @@ func (p *Pinger) Stop() { } } +// Reset sets the RTTs and the sent and received counts +// back to zero so that Run can be re-used on the same +// instance. +func (p *Pinger) Reset() { + p.done = make(chan bool) + p.rtts = make([]time.Duration, 0) + p.PacketsSent = 0 + p.PacketsRecv = 0 +} + func (p *Pinger) finish() { handler := p.OnFinish if handler != nil {