Standard library / time

time.After()

Wait for one timer delivery; useful for a one-off timeout. The channel is not closed after delivery. On Go 1.23, channel-timer rules depend on the main module go directive and GODEBUG=asynctimerchan; see compatibility notes. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func After(d Duration) <-chan Time

Parameters & Attributes

NameTypeDescription
dDurationElapsed duration or interval.

Return Value

<-chan Time

Wait for one timer delivery; useful for a one-off timeout.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func main() { fmt.Println(!(<-time.After(0)).IsZero()) }
Go Reference