time zero check

判断time是否为空(如果空,就不更新)
time字段,在更新的时候,不管是否获取最新事件,都会去更新表;这里加入判空,如果为空,就不更新该字段
This commit is contained in:
knull-cn 2019-12-02 18:04:46 +08:00 committed by GitHub
parent 59408390c2
commit f93c350e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,6 +139,11 @@ func isBlank(value reflect.Value) bool {
return value.Float() == 0 return value.Float() == 0
case reflect.Interface, reflect.Ptr: case reflect.Interface, reflect.Ptr:
return value.IsNil() return value.IsNil()
case reflect.Struct://time zero check;
v,ok:= value.Interface().(time.Time)
if ok {
return !v.IsZero()
}
} }
return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface()) return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface())