在错误情况下,我尝试返回 nil
,这会引发错误:
cannot use nil as type time.Time in return argument
time.Time
的 zero
值是多少?
最佳答案
您应该使用 Time.IsZero()
代替函数:
func (Time) IsZero
或
func (t Time) IsZero() bool
IsZero reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.
关于time - Go 中 time.Time 的 `zero` 值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23051973/