Hi Rog, Yes, I am aware of that feature, but that does not expose an actual monotonic timestamp reading to the user, and so I stand by my claim that the Go runtime does not expose a monotonic clock to the user (like the hlc package provides).
https://go.googlesource.com/proposal/+/master/design/12914-monotonic.md lets you take the difference of two local timestamps, but does not give an absolute time reading that would correspond to any actual "time of day". So I still see hlc as valuable for that otherwise un-addressed use case. - Jason On Thursday, February 26, 2026 at 1:42:15 PM UTC-3 roger peppe wrote: > This looks potentially useful, thanks. > One thing I'd pick up from the README, which says: > > > The Go standard library time package does not provide a user-accessible > monotonic clock. > > That might have been true at one point, but is no longer the case. > See > https://go.googlesource.com/proposal/+/master/design/12914-monotonic.md > for details of the > monotonic clock proposal. > > In short, time.Time.Sub on timestamps derived from time.Now will give the > monotonic time interval > between them, regardless of leap seconds and the like. > > So: > t0 := time.Now() > t1 := time.Now() > d := t1.Sub(t0) > > will guarantee that d is non-negative (assuming the underlying system > provides access to a monotonic clock). > > > On Sat, 24 Jan 2026 at 18:22, Jason E. Aten <[email protected]> wrote: > >> I have open sourced my hybrid physical/logical clock package, here. >> >> https://github.com/glycerine/hlc >> >> HLC are useful for solving various problems in distributed systems. >> >> The concept of an HLC was invented in this 2014 paper, to combine and >> preserve the convenient features of both physical and logical clocks: >> >> "Logical Physical Clocks and Consistent Snapshots in Globally Distributed >> Databases" by Sandeep Kulkarni, Murat Demirbas, Deepak Madeppa, Bharadwaj >> Avva, and Marcelo Leone. >> >> https://cse.buffalo.edu/tech-reports/2014-04.pdf >> >> See for instance their use in CockroachDB and MongoDB as alternatives to >> Spanner's TrueTime approach when atomic clocks are unavailable. >> >> https://cse.buffalo.edu/~demirbas/publications/augmentedTime.pdf >> >> https://github.com/AugmentedTimeProject/AugmentedTimeProject >> >> >> https://muratbuffalo.blogspot.com/2025/01/use-of-time-in-distributed-databases.html >> >> Enjoy, >> >> Jason >> >> -- >> 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 [email protected]. >> To view this discussion visit >> https://groups.google.com/d/msgid/golang-nuts/7718c100-4382-4f87-992e-7a3839331042n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/7718c100-4382-4f87-992e-7a3839331042n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/da8ba749-b290-4abf-978b-e1db336582dfn%40googlegroups.com.
