I seem to be having issues with the accuracy of time.Sleep and time.Ticker. 

Running this application below gives me these results:
2017-03-31 17:30:00 +0000 UTC - next tick
Expected: 2017-03-31 17:30:00 +0000 UTC
Current : 2017-03-31 17:30:02.871095796 +0000 UTC


package main

import (
"fmt"
"time"
)

func main() {
ct := time.Now()

nextTick := time.Date(ct.Year(), ct.Month(), ct.Day(), ct.Hour(), 
((ct.Minute()/3)+1)*3, 0, 0, time.Local)
fmt.Println(nextTick, "- next tick")
diff := nextTick.Sub(time.Now())
time.Sleep(diff)
fmt.Printf("Current : %v\n", time.Now())
fmt.Printf("Expected: %v\n", nextTick)
}





I also opened up a Issue on github relating to the ticker.
https://github.com/golang/go/issues/19810

I was wondering if anyone else was having issues with these parts of the 
lib?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to