package time
+// Sleep pauses the current goroutine for the duration d.
+func Sleep(d Duration)
+
func nano() int64 {
sec, nsec := now()
return sec*1e9 + int64(nsec)
return NewTimer(d).C
}
-// AfterFunc waits at least ns nanoseconds before calling f
+// AfterFunc waits for the duration to elapse and then calls f
// in its own goroutine. It returns a Timer that can
// be used to cancel the call using its Stop method.
-func AfterFunc(ns int64, f func()) *Timer {
+func AfterFunc(d Duration, f func()) *Timer {
t := &Timer{
r: runtimeTimer{
- when: nano() + ns,
+ when: nano() + int64(d),
f: goFunc,
arg: f,
},