Elapsed retorna o tempo decorrido (funciona mesmo com timer rúdando)
()
| 91 | |
| 92 | // Elapsed retorna o tempo decorrido (funciona mesmo com timer rúdando) |
| 93 | func (t *Timer) Elapsed() time.Duration { |
| 94 | t.mu.Lock() |
| 95 | defer t.mu.Unlock() |
| 96 | |
| 97 | if t.running { |
| 98 | return time.Since(t.startTime) |
| 99 | } |
| 100 | if !t.stopTime.IsZero() { |
| 101 | return t.stopTime.Sub(t.startTime) |
| 102 | } |
| 103 | return 0 |
| 104 | } |
| 105 | |
| 106 | // IsRunning retorna se o timer está em execução |
| 107 | func (t *Timer) IsRunning() bool { |