Re: [dev] golang: time.Tick() and ntp

From: Silvan Jegen <>
Date: Wed, 8 Oct 2014 13:18:08 +0200


On Wed, Oct 08, 2014 at 12:23:59PM +0200, Markus Teich wrote:
> Heyho,
> I am using a status bar script written in go[0]. Recently I have noticed two
> problems related to the time display, but first here is the relevant part of the
> code:
> for clock := range time.Tick(time.Second) {
> // …
> clock.Format("Mon 02 15:04:05")
> // …
> }
> Now the first problem occured when I was travelling to another timezone and
> updated my timezone information. Since clock only get's initialized once, we
> don't catch the new timezone info and the displayed time stays in the old
> timezone until the script is restarted.

I think you could use to
occasionally check wether the time zone has changed since the script has
been started and then use to
output the time.

> The second problem is when using ntp to synchronize the clock. In this case the
> channel provided by time.Tick() stops to send on that channel and therefore the
> whole loop stops and the status bar is not updated anymore.

In this issue
in answer #30 they mention that they use a monotonic clock on Linux
now with Go 1.3 and up which should solve this (this is the commit ). What platform
and Go version are you using?
Received on Wed Oct 08 2014 - 13:18:08 CEST

This archive was generated by hypermail 2.3.0 : Wed Oct 08 2014 - 13:24:07 CEST