获取二维切片的尺寸

Lets say I have a 4 by 5 2d array

array := [][]byte{
    {1, 0, 1, 0, 0},
    {1, 0, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 0, 0, 1, 0},
}

How do I get the columns and widths of this array? I want to do a nested loop over this array but the array passed in the function may vary in dimensions.

Just get the len of array and the len of any element of array.

len(array) // 4
len(array[0]) // 5

As a note, you are using a 2d slice, not array. Read more about Go slices here.