Go checks array bounds at runtime:
arr := [3]int{1, 2, 3}
fmt.Println(arr[5]) // panic: index out of range
This panic prevents memory corruption but crashes your program. Always verify indices are within bounds, especially with user input.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Index safety
Go checks array bounds at runtime:
arr := [3]int{1, 2, 3}
fmt.Println(arr[5]) // panic: index out of range
This panic prevents memory corruption but crashes your program. Always verify indices are within bounds, especially with user input.