英文:
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 section 是 time 包文档 中描述单调时钟和墙钟时间的部分。该部分涵盖了从数据库中读取时间的场景。
请参阅 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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论