代码拉取完成,页面将自动刷新
package gcache
import (
"sync"
"time"
)
type Clock interface {
Now() time.Time
}
type RealClock struct{}
func NewRealClock() Clock {
return RealClock{}
}
func (rc RealClock) Now() time.Time {
t := time.Now()
return t
}
type FakeClock interface {
Clock
Advance(d time.Duration)
}
func NewFakeClock() FakeClock {
return &fakeclock{
// Taken from github.com/jonboulle/clockwork: use a fixture that does not fulfill Time.IsZero()
now: time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC),
}
}
type fakeclock struct {
now time.Time
mutex sync.RWMutex
}
func (fc *fakeclock) Now() time.Time {
fc.mutex.RLock()
defer fc.mutex.RUnlock()
t := fc.now
return t
}
func (fc *fakeclock) Advance(d time.Duration) {
fc.mutex.Lock()
defer fc.mutex.Unlock()
fc.now = fc.now.Add(d)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。