Multi dimentional arrays in Go
Making two dimensional array is very easy in Go. The following code is an example based on the rosettacode [1].
// go run 2d.go
package main
import "fmt"
func main(){
two_d_array := make([][]int, 10)
for i := range two_d_array{
two_d_array[i] = make([]int, i)
}
for i := range two_d_array{
fmt.Printf("The size of two_d_array[%d] is %d\n", i, len(two_d_array[i]))
}
}
You should see the following result
The size of two_d_array[0] is 0
The size of two_d_array[1] is 1
The size of two_d_array[2] is 2
The size of two_d_array[3] is 3
The size of two_d_array[4] is 4
The size of two_d_array[5] is 5
The size of two_d_array[6] is 6
The size of two_d_array[7] is 7
The size of two_d_array[8] is 8
The size of two_d_array[9] is 9
[1] http://rosettacode.org/wiki/Create_a_two-dimensional_array_at_runtime#Go