编译错误:非常数数组绑定(动态编程)

Im trying to solve the minimum path sum problem of Dynamic programming using golang and below is my program for that which shows compilation error.

enter code here
func minPathSum(grid [][]int) int {
    var dp[m+1][n+1] int
    dp[0][0] = grid[0][0]

    //for column initialization
    for i := 0; i <= m; i++ {
        dp[i][0] = dp[i-1][0] + grid[i][0]
    }

    //for row initialization
    for j := 0; j <= n; j++ {
        dp[0][j] = dp[0][j-1] + grid[0][j]
    }
    for i := 0; i <= m; i++ {
        for j := 0; j <= n; j++ {
            dp[i][j] = min(dp[i][j-1], dp[i-1][j], dp[i-1][j-1]) + grid[i][j]
        }
    }
    return dp[m][n]
}

As @Motakjuq mentioned in comment: you cannot define a dynamic array, both dimensions must be constant for an array, but slice will help you.

Use something like this:

dp := make([][]int, m)
for i := range dp {
    dp[i] = make([]int, n)
}