Now returns the virtual clock's current time, and advances it according to its step configuration.
()
| 142 | // Now returns the virtual clock's current time, and advances it |
| 143 | // according to its step configuration. |
| 144 | func (c *Clock) Now() time.Time { |
| 145 | c.init() |
| 146 | rt := c.maybeGetRealTime() |
| 147 | |
| 148 | c.mu.Lock() |
| 149 | defer c.mu.Unlock() |
| 150 | |
| 151 | step := c.step |
| 152 | if c.skipStep { |
| 153 | step = 0 |
| 154 | c.skipStep = false |
| 155 | } |
| 156 | c.advanceLocked(rt, step) |
| 157 | |
| 158 | return c.present |
| 159 | } |
| 160 | |
| 161 | func (c *Clock) maybeGetRealTime() time.Time { |
| 162 | if c.realTimeClock == nil { |