This question already has an answer here:
I want to allocate space for a 2 dimensional array and I want to do so in a clean way.
address [10]int
myLength := len(address)
// 1. but this not work at all
matrix := [myLength][myLength]byte
// 2. and this initializes 10 arrays with length 0
matrix := make([][]int, myLength, myLength)
I am getting an error for the first attempt:
non-constant array bound l
PS not solved by: How to allocate a non-constant sized array in Go
</div>
There's no "one liner" way to do that. simply do:
matrix := make([][]int, myLength)
for i : = 0; i < myLength; i++ {
matrix[i] = make([]int, myLength)
}