Documentation
¶
Overview ¶
Package timex 提供可注入时钟和确定性假时钟。
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
FakeClock is a deterministic mutable clock for tests.
func NewFakeClock ¶
type FixedClock ¶
type FixedClock struct {
// contains filtered or unexported fields
}
FixedClock always returns the configured time.
func NewFixedClock ¶
func NewFixedClock(now time.Time) FixedClock
Example ¶
package main
import (
"time"
"github.com/ZoneCNH/kernel/timex"
)
func main() {
fixed := time.Date(2026, 6, 1, 0, 0, 0, 0, time.UTC)
_ = timex.NewFixedClock(fixed).Now()
}
Output:
func (FixedClock) Now ¶
func (c FixedClock) Now() time.Time
Click to show internal directories.
Click to hide internal directories.