草庐IT

ProductionInfo

全部标签

Golang 反射(reflect)在 slice 中获取结构成员

我有以下结构:typeProductionInfostruct{StructA[]struct{Field1stringField2int}我将从ProductionInfo类型的StructA中提取字段名称和类型。但我不明白如何。谁能帮帮我? 最佳答案 使用反射包:f,_:=reflect.TypeOf(ProductionInfo{}).FieldByName("StructA")t:=f.Type.Elem()fori:=0;i 关于Golang反射(reflect)在slice中