【发布时间】:2017-08-16 05:49:03
【问题描述】:
我有一个嵌套(非嵌入)结构,其中一些字段类型是数组。
如何检查此结构的实例是否为空? (不使用迭代!!)
请注意,不能使用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"`
}
【问题讨论】:
-
迭代是唯一的可能。