
golang笔记
「已注销」
这个作者很懒,什么都没留下…
展开
-
golang时间从数据库读取时间
package mainimport ( "database/sql/driver" "encoding/json" "fmt" "time")type NullTime struct { Time time.Time Valid bool // 是否有值}//实现它的赋值方法(注意,这个方属于指针)func (nt *NullTime) Scan(value in原创 2016-11-10 15:45:35 · 9834 阅读 · 1 评论 -
golang的json的时间格式化解决方案
golang的json的时间格式化解决方案1.通过数据查询的时候指定号格式,这样就不要再转格式了 2.通过time.Time类型穿件别名,然后为这个别名类实现MarshalJSON方法。以下来自golang的原来注释 If an encountered value implements the Marshaler interface // and is not a nil pointer原创 2016-11-04 13:46:50 · 8206 阅读 · 3 评论