I fixed your example with some explanatory comments: https://play.golang.org/p/zwt78CPwxk_o
package main import ( "fmt" ) func main() { Af(5) } func Af ( N int) { //Initialize outer array, you get an array of 25 nil arrays M := make( [][]uint16, N*N,N*N) for y:=0; y< N; y++ { // Initialize inner array, it's now got 25 elements in it. M[y] = make([]uint16, N*N, N*N) for x :=0; x< N; x++ { M[y][x] = uint16(100*y +x) } } for y :=0; y< N; y++ { fmt.Printf("\n y= %3d", y ) for x :=0; x< N; x++ { fmt.Printf(" %3d ", M[x][y] ) } } fmt.Printf("\n>>>>>>>>>>" ) } On Sat, Apr 20, 2019 at 10:10 PM <lgod...@gmail.com> wrote: > Here's the snippet I'm trying to run > > package main > import ( "fmt" ) > > func main() { > Af(5) > } > > func Af ( N int) { > > //var M = new([N][N]uint16) !compiler error > //var M = make([N][N]uint16) !compiler error > > //var M = make([][]uint16, N*N) ## run-time error > > // run-time error > M := make( [][]uint16, N*N,N*N) > for y:=0; y< N; y++ { > for x :=0; x< N; x++ { > M[y][x] = uint16(100*y +x) > } } > > for y :=0; y< N; y++ { > fmt.Printf("\n y= %3d", y ) > for x :=0; x< N; x++ { > fmt.Printf(" %3d ", M[x][y] ) > } } > fmt.Printf("\n>>>>>>>>>>" ) > } > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.