How do I convert a database row into a struct

后端 未结 7 926
谎友^
谎友^ 2020-12-07 14:07

Let\'s say I have a struct:

type User struct {
    Name  string
    Id    int
    Score int
}

And a database table with the same schema. Wh

7条回答
  •  时光取名叫无心
    2020-12-07 14:46

    there's package just for that: sqlstruct

    unfortunately, last time I checked it did not support embedded structs (which are trivial to implement yourself - i had a working prototype in a few hours).

    just committed the changes I made to sqlstruct

提交回复
热议问题