Since and Until methods of simulator are using exclusive lock mode, which is not required here:
// Since returns the time elapsed since t.
func (s *Simulator) Since(t time.Time) time.Duration {
s.Lock()
defer s.Unlock()
return s.now.Sub(t)
}
// Until returns the duration until t.
func (s *Simulator) Until(t time.Time) time.Duration {
s.Lock()
defer s.Unlock()
return t.Sub(s.now)
}
It can be replaced with shared lock, as done in Now method:
// Now returns the current time.
func (s *Simulator) Now() time.Time {
s.RLock()
defer s.RUnlock()
return s.now
}