Пример #1
0
// BeforeFunc spies on cfg.BeforeFunc calls, sending passed time.Time
// to the returned channel.
//
// If cfg.BeforeFunc is non-nil, it is called after the value is sent.
func (d *Driver) BeforeFunc(cfg *keygen.Config) <-chan time.Time {
	ch := make(chan time.Time, d.ChanCap)
	fn := cfg.BeforeFunc

	cfg.BeforeFunc = func(t time.Time) bool {
		ch <- t

		if fn != nil {
			return fn(t)
		}

		return keygen.DefaultBefore(t)
	}

	return ch
}