Logo

Programming-Idioms

History of Idiom 185 > diff from v16 to v17

Edit summary for version 17 by programming-idioms.org:
[Go] Fix spaces in imports

Version 16

2019-09-27, 07:37:49

Version 17

2019-09-27, 07:50:34

Idiom #185 Execute function in 30 seconds

Schedule the execution of f(42) in 30 seconds.

Idiom #185 Execute function in 30 seconds

Schedule the execution of f(42) in 30 seconds.

Extra Keywords
future
Extra Keywords
future
Imports
import  "time"
Imports
import "time"
Code
timer := time.AfterFunc(
	30*time.Second,
	func() {
		f(42)
	})
Code
timer := time.AfterFunc(
	30*time.Second,
	func() {
		f(42)
	})
Comments bubble
f is wrapped in an anonymous func having 0 arg and 0 return value.

The timer instance can be used to cancel the call.
Comments bubble
f is wrapped in an anonymous func having 0 arg and 0 return value.

The timer instance can be used to cancel the call.
Doc URL
https://golang.org/pkg/time/#AfterFunc
Doc URL
https://golang.org/pkg/time/#AfterFunc
Demo URL
https://play.golang.org/p/X8Bvs1m1bD5
Demo URL
https://play.golang.org/p/X8Bvs1m1bD5