dongtaogou6226 2018-01-18 16:57
浏览 51

如何在不解析表行的情况下更改结构上的日期格式,例如“ yyyy-mm-dd”?

I would to change EntryDate format like yyyy-mm-dd formated on the struct,

type Value struct {
    Id uint `json:”id”`
    EntryDate time.time `json:”entry_date”`
    ProductId int `json:"product_id"`
    Value float64 `json:”value”`
}

By default the result like this

{
  Id: 11,
  EntryDate: "2017-11-23T00:00:00Z",
  product_id: 1,
  Value: 932.3
},

How to change EntryDate format like "yyyy-mm-dd" on the struct without parsing on the code ?

  • 写回答

2条回答 默认 最新

  • douwen3127 2018-01-19 10:41
    关注

    Change the struct type without parsing at loops ? check this article http://sosedoff.com/2016/07/16/golang-struct-tags.html

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致