我有一个嵌套的(不嵌入的)结构,其中一些字段类型是数组。检查具有数组字段的空结构
如何检查此结构的实例是否为空? (不使用迭代!!)
请注意,不能使用StructIns == (Struct{})
或空的实例!这段代码有此错误:
invalid operation: user == model.User literal (struct containing model.Configs cannot be compared)
user.Configs.TspConfigs:
type TspConfigs struct {
Flights []Flights `form:"flights" json:"flights"`
Tours []Tours `form:"tours" json:"tours"`
Insurances []Insurances`form:"insurances" json:"insurances"`
Hotels []Hotels `form:"hotels" json:"hotels"`
}
迭代是唯一的可能性。 – Flimzy