Gorm always return structs with nil values

断了今生、忘了曾经 提交于 2019-12-02 12:13:06

All the fields in your gameCenterlog struct are lower case so they're not exported. Non-exported fields are invisible to reflection so they're invisible to Gorm.

If you capitalize the fields:

type gameCenterLog struct {
    Tm      time.Time
    Seq     int
    Uid     int
    ...

then Gorm will be able to see them give values. Gorm should be able to figure out the mapping from the column names in PostgreSQL to the struct fields in Go but you can use gorm:"column:..." struct tags if it doesn't.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!