Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseTimeStrict ¶
ParseTimeStrict parses a formatted string and returns the time value it represents. The output is identical to time.Parse except it returns an error for strings that don't format to the input value.
An example where the output differs from time.Parse would be: parseTimeStrict("1/2/06", "11/31/15")
- time.Parse returns "2015-12-01 00:00:00 +0000 UTC"
- ParseTimeStrict returns an error
Types ¶
type RandomTicker ¶
RandomTicker is similar to time.Ticker but ticks at random intervals between the min and max duration values (stored internally as int64 nanosecond counts).
func NewRandomTicker ¶
func NewRandomTicker(min, max, durationKind time.Duration) *RandomTicker
NewRandomTicker returns a pointer to an initialized instance of the RandomTicker. Min and max are durations of the shortest and longest allowed ticks. Ticker will run in a goroutine until explicitly stopped. durationKind must be one of the following constants: time.Nanosecond, time.Microsecond, time.Millisecond, time.Second, time.Minute, time.Hour or it panics. AFAIK: It uses time.NewTimer under the hood which increases memory usage in tight loops a lot as the timer cannot be garbage collected.
func (*RandomTicker) NextInterval ¶
func (rt *RandomTicker) NextInterval() time.Duration
NextInterval returns a random duration between max and min in the provided durationKind.
func (*RandomTicker) Stop ¶
func (rt *RandomTicker) Stop()
Stop terminates the ticker goroutine and closes the C channel.