func Now() time.Time {
	if MockMode {
		return currentTimeMock
	} else {
		return time.Now()
	}
}
Returns the current time.
If Mock Mode is set, this will be the sum of all Durations passed into Elapse calls;
otherwise it will be the true system time.
package timing
import (
	"sync"
	"time"
)
var MockMode = false
var currentTimeMock = time.Unix(0, 0)
var mockTimers = make([]*mockTimer, 0)
var mockTimerMu = new(sync.Mutex)
type Timer interface {
	C() <-chan time.Time
	Reset(d time.Duration) bool
	Stop() bool
}
type realTimer struct {
	*time.Timer
}
func (t *realTimer) C() <-chan time.Time {
	return t.Timer.C
}
func (t *realTimer) Reset(d time.Duration) bool {
	t.Stop()
	return t.Timer.Reset(d)
}
func (t *realTimer) Stop() bool {
	if !t.Timer.Stop() {
		select {
		case <-t.Timer.C:
			return true
		default:
			return false
		}
	}
	return true
}
type mockTimer struct {
	EndTime time.Time
	Chan    chan time.Time
	fired   bool
	toRun   func()
}
func (t *mockTimer) C() <-chan time.Time {
	return t.Chan
}
func (t *mockTimer) Reset(d time.Duration) bool {
	wasActive := removeMockTimer(t)
	t.EndTime = currentTimeMock.Add(d)
	if d > 0 {
		mockTimerMu.Lock()
		mockTimers = append(mockTimers, t)
		mockTimerMu.Unlock()
	} else {
		t.Chan <- currentTimeMock
	}
	return wasActive
}
func (t *mockTimer) Stop() bool {
	if !removeMockTimer(t) {
		select {
		case <-t.Chan:
			return true
		default:
			return false
		}
	}
	return true
}
func NewTimer(d time.Duration) Timer {
	if MockMode {
		t := mockTimer{currentTimeMock.Add(d), make(chan time.Time, 1), false, nil}
		if d == 0 {
			t.Chan <- currentTimeMock
		} else {
			mockTimerMu.Lock()
			mockTimers = append(mockTimers, &t)
			mockTimerMu.Unlock()
		}
		return &t
	} else {
		return &realTimer{time.NewTimer(d)}
	}
}
func After(d time.Duration) <-chan time.Time {
	return NewTimer(d).C()
}
func AfterFunc(d time.Duration, f func()) Timer {
	if MockMode {
		mockTimerMu.Lock()
		t := mockTimer{currentTimeMock.Add(d), make(chan time.Time, 1), false, f}
		mockTimerMu.Unlock()
		if d == 0 {
			go f()
			t.Chan <- currentTimeMock
		} else {
			mockTimerMu.Lock()
			mockTimers = append(mockTimers, &t)
			mockTimerMu.Unlock()
		}
		return &t
	} else {
		return &realTimer{time.AfterFunc(d, f)}
	}
}
func Sleep(d time.Duration) {
	<-After(d)
}
func Elapse(d time.Duration) {
	requireMockMode()
	mockTimerMu.Lock()
	currentTimeMock = currentTimeMock.Add(d)
	mockTimerMu.Unlock()
	mockTimerMu.Lock()
	for _, t := range mockTimers {
		t.fired = false
		if !t.EndTime.After(currentTimeMock) {
			if t.toRun != nil {
				go t.toRun()
			}
			select {
			case <-t.Chan:
			default:
			}
			t.Chan <- currentTimeMock
			t.fired = true
		}
	}
	mockTimerMu.Unlock()
	remainingTimers := make([]*mockTimer, 0)
	mockTimerMu.Lock()
	for _, t := range mockTimers {
		if !t.fired {
			remainingTimers = append(remainingTimers, t)
		}
	}
	mockTimers = remainingTimers
	mockTimerMu.Unlock()
}