fix golint issues in core/timex (#517)

This commit is contained in:
Kevin Wan
2021-02-24 16:27:11 +08:00
committed by GitHub
parent 04b0f26182
commit ef146cf5ba
4 changed files with 10 additions and 0 deletions

View File

@@ -5,14 +5,18 @@ import "time"
// Use the long enough past time as start time, in case timex.Now() - lastTime equals 0.
var initTime = time.Now().AddDate(-1, -1, -1)
// Now returns a relative time duration since initTime, which is not important.
// The caller only needs to care about the relative value.
func Now() time.Duration {
return time.Since(initTime)
}
// Since returns a diff since given d.
func Since(d time.Duration) time.Duration {
return time.Since(initTime) - d
}
// Time returns current time, the same as time.Now().
func Time() time.Time {
return initTime.Add(Now())
}