前の投稿の続き
1.reflectで取り出し
iter := reflect.ValueOf(*_data.EachTaxRate).MapRange()
for iter.Next() {
k := iter.Key()
v := iter.Value()
fmt.Println(k,":",v);
}
2.型変換
・string
fmt.Sprintf("%s",k);
・int
_v,_ := strconv.Atoi(fmt.Sprintf("%v",v));
3.code
var tax_percent []string;
var tax_value []int;
iter := reflect.ValueOf(*_data.EachTaxRate).MapRange()
for iter.Next() {
k := iter.Key()
v := iter.Value()
fmt.Println(k,":",v);
tax_percent = append (tax_percent, fmt.Sprintf("%s",k));
_v,_ := strconv.Atoi(fmt.Sprintf("%v",v));
tax_value = append (tax_value, _v);
}
fmt.Println(tax_percent,tax_value);