I am new to GO lang. what I am trying to do is, I have 2D array of int and I want to set the values from the last index of 2D array since I am solving one dynamic programming question. GO lang is not allowing to set the values to any index if it is not initialised. I solved this by looping through the 2D array and setting values explicitly described in below code, but I am not sure is this the way GO expecting or can I directly assign values to any index of 2D array without initialising it.
var dp = [][]int {}
for i:=0; i<m; i++{
var arr = make([]int, n)
for j:=0;j<n;j++{
arr = append(arr, 0)
}
dp = append(dp, arr)
}