1数据源
[
[
{2714 白色 0xc000180d80 0xc0000f1110 0xc000044e40}
{2715 屎黄色 0xc000180ea0 0xc0000f11f0 0xc000044ea0}
{2720 绿色 0xc000180fc0 0xc0000f1340 0xc000045020}
]
[
{2717 纯棉 0xc000181320 0xc0000f1420 0xc000045380}
]
[
{2716 30寸 0xc000181680 0xc0000f1500 0xc00099c2a0}
{2718 60寸 0xc0001817a0 0xc0000f15e0 0xc00099c300}
]
]
2代码实现
func(this *GoodsController)GetSku(goods_attrs [][]models.GoodsAttr)([][]models.GoodsAttr){
arrlen:=len(goods_attrs)//列
sku:=make([][]models.GoodsAttr,0)
for _,val :=range goods_attrs[0] {
temps := make([]models.GoodsAttr, 0)
temps = append(temps,val)
sku =append(sku,temps)
}
for i:=0;i<arrlen-1;i++{
skuarr:=make([][]models.GoodsAttr,0)
for _,val:=range sku{
for _,vals :=range goods_attrs[i+1]{
temp:=make([]models.GoodsAttr,0)
temp=append(temp,val...)
temp=append(temp,vals)
skuarr=append(skuarr,temp)
}
}
sku=skuarr
}
return sku
}