golang sqlx查询时, struct字段冲突

type TA struct {

  Id int64 `db:"id"`

}

 

type TB struct {

  Id int64 `db:"id"`

}

 

type TC struct {

  TA

  TB

}

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

 

如果TC的结构体是

type TC struct {

  TB

  TA

}

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

 

posted @ 2019-05-14 11:07  knox大树  阅读(662)  评论(0编辑  收藏  举报