Skip to content

Commit

Permalink
time: in NewTicker, document that the 1st tick comes after d
Browse files Browse the repository at this point in the history
Fixes #42245

Change-Id: I3b298ab6be65569389873d68bd3c6e49cf892c69
Reviewed-on: https://go-review.googlesource.com/c/go/+/265818
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Rob Pike <[email protected]>
Trust: Alberto Donizetti <[email protected]>
  • Loading branch information
ALTree authored and robpike committed Nov 18, 2020
1 parent 041a4e4 commit bcfaeca
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/time/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ type Ticker struct {
r runtimeTimer
}

// NewTicker returns a new Ticker containing a channel that will send the
// time with a period specified by the duration argument.
// It adjusts the intervals or drops ticks to make up for slow receivers.
// The duration d must be greater than zero; if not, NewTicker will panic.
// Stop the ticker to release associated resources.
// NewTicker returns a new Ticker containing a channel that will send
// the time on the channel after each tick. The period of the ticks is
// specified by the duration argument. The ticker will adjust the time
// interval or drop ticks to make up for slow receivers.
// The duration d must be greater than zero; if not, NewTicker will
// panic. Stop the ticker to release associated resources.
func NewTicker(d Duration) *Ticker {
if d <= 0 {
panic(errors.New("non-positive interval for NewTicker"))
Expand Down

0 comments on commit bcfaeca

Please sign in to comment.