99网
您的当前位置:首页golangsqlx查询时,struct字段冲突

golangsqlx查询时,struct字段冲突

来源:99网
golangsqlx查询时,struct字段冲突

type TA struct {  Id int `db:\"id\"`}

type TB struct {  Id int `db:\"id\"`}

type TC struct {  TA  TB}

如上的sql和结构体, 当查询sql,⽤TC结构体封装时, 有两个id字段, 那么数据库中id的值是在TB的id中

如果TC的结构体是type TC struct {  TB  TA}

这样, 那么id的值就是在TA中

因篇幅问题不能全部显示,请点此查看更多更全内容