To my surprise, this compiled
fmt.Println(time.Second * time.Second)
The result is nonsense
277777h46m40s
It doesn't make any sense to multiply a duration by duration and get another duration.
What's going on?
To my surprise, this compiled
fmt.Println(time.Second * time.Second)
The result is nonsense
277777h46m40s
It doesn't make any sense to multiply a duration by duration and get another duration.
What's going on?
Duration 类型只是一个 int64,将持续时间表示为纳秒计数
类型持续时间 int64
Duration 将两个瞬间之间的经过时间表示为 int64 纳秒计数。
因此,将一个持续时间乘以另一个得出的结果是将每个持续时间乘以纳秒数。在我的示例中,这给出了 10 亿纳秒,或277777h46m40s
. 废话,但定义明确!