xorm使用map kv更新日期时间类型字段的时区问题
最近使用xorm更新db的时候碰到一个挺有意思的问题,db中字段类型是日期datetime,对应go model中的字段是time.Time类型,在分别使用model和map两种方式进行更新时,使用model的方式更新能得到正确结果,db中的日期能被更新成当地时间;使用map kv的方式进行更新时db中的字段被更新成了格林尼治标准时间。都是取的go time.Now为什么更新结果不一样呢? // demo type TimeTest struct { ID int64 `xorm:"not null pk autoincr INT(11) 'id'"` UpdateTime time.Time `xorm:"update_time"` } func UpdateTime(o *xorm.Session) { o.Table(new(TimeTest)).Where("id = ?", 1).Update(&TimeTest{ UpdateTime: time.Now(), }) o.Table(new(TimeTest)).Where("id = ?", 1).Update(map[string]interface{}{ "update_time": time.Now(), }) } ...