To execute the code with some delay only once, the Timer from the time package can be used. The concept of how this works is the same as described in the previous recipe, Running the code block periodically.
The Timer contains the C channel, which delivers the tick after a given time. After that, no other ticks are delivered through the channel.
The same functionality delivers the AfterFunc function of the time package. It just simplifies the usage. Note that there is no channel needed. The sample code uses the sync.WaitGroup to wait until the given function is executed.
The time.After is the last option in the preceding example. The function returns a channel that delivers the tick after a given period. Note the difference ...