What is wall in golang Time?

huangapple go评论86阅读模式
英文:

What is wall in golang Time?

问题

wall 是 golang Time 结构体中的一个字段,它表示时间的墙时钟纳秒。在你的例子中,wall 字段的值从 454722000 变为了 0,导致了差异。这可能是由于不同的时间操作或转换引起的。具体原因需要查看你的代码和操作来确定。

英文:

I was testing a feature where I had to write a record with created_at field which is of type time.Time into a Mysql table. When I read the same record back I get following diff.

                                    Time: (time.Time) {
                                -    wall: (uint64) 454722000,
                                +    wall: (uint64) 0,

What is wall in golang Time and why are they different?

答案1

得分: 2

Monotonic Clocks sectiontime 包文档 中描述单调时钟和墙钟时间的部分。该部分涵盖了从数据库中读取时间的场景。

请参阅 Equal 以获取有关如何比较时间值的信息。

英文:

The Monotonic Clocks section of the time package documentation describes monatomic and wall clock time in detail. The section covers the scenario of reading a time from a database.

See Equal for information on how to compare time values.

答案2

得分: 1

我对此的真正原因与“纳秒”有关。显然,当我写入数据库时,“纳秒”会被剥离。所以我创建了一个函数,它可以返回当前时间,但不包括“纳秒”。

英文:

The real reason for me has to do with nano seconds. Apparently when I write to db nano seconds are stripped off. So what I did is created a function that would return me current time but without nano seconds.

huangapple
  • 本文由 发表于 2022年3月11日 10:44:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/71433080.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定