【发布时间】:2021-12-06 01:40:30
【问题描述】:
数据库实体、保留和数据映射。
type User struct{
UserId int
Org int
Name string
Password string
Sex int
Age int
Avatar string
}
type Address struct{
AddressId int
UserId int
Province int
City int
District int
Address int
Description string
}
在DAO中,我想对实体结构进行合并、剪切、扩展…… 例如:
type UserInfo struct{
User
[]Address
}
但匿名结构是嵌入的,只能完整引用。如何引用一些字段?
type UserInfo struct{
User
[]Address
Password string `json:"-"`
Sex int `json:"-"`
Age int `json:"-"`
}
【问题讨论】: