I have a dynamic multi dimension array, I need to fill dynamically from the loop. how can i define the array and fill the data.
Here is the code which im trying
var arrDetails[][]string
var index int = 0
for _, orderdetails := range ordersfromdb {
arrDetails[index]["OrderNumber"] = "001"
arrDetails[index]["customernum"] = "cust_001"
arrDetails[index]["orderstatus"] = "open"
arrDetails[index]["orderprice"] = "200"
index++
}
error which im facing:
non-integer slice index "OrderNumber"
non-integer slice index "customernum"
non-integer slice index "orderstatus"
non-integer slice index "orderprice"
I have done the same in php and works perfect:
for ($i=0;$i<5:$i++)
{
$arr_orderdetails[$i]["OrderNumber"] = "001";
$arr_orderdetails[$i]["customernum"] = "cust_001";
$arr_orderdetails[$i]["orderstatus"] = "open";
$arr_orderdetails[$i]["orderprice"] = "200";
}
I'm new to golang, not able to find where it is going wrong, any help much appreciated.
Thanks :)