On a MacBook Pro, 2.6 GHz Intel Core i7, 8 GB 1600 MHz DDR3, I get:

2017-03-31 15:51:00 -0600 MDT - next tick

Current : 2017-03-31 15:51:00.00008893 -0600 MDT

Expected: 2017-03-31 15:51:00 -0600 MDT

 
On Friday, March 31, 2017 at 1:44:44 PM UTC-6, apollo wellstein wrote:
>
> 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