Standard library / time
time.Ticker
Periodic channel timer. Use NewTicker; C delivers ticks, Stop does not close it, and slow receivers may miss ticks. Expected stdout: 'tick\n'.
Formal Syntax & Structure
go syntaxgo
type Ticker struct { C <-chan Time; /* unexported fields */ }Working Example
Example Snippetgo
package main
import ( "fmt" "time")
func main() { t := time.NewTicker(time.Millisecond); defer t.Stop(); <-t.C; fmt.Println("tick") }