Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Array index out of range - run time

package main

import (
	"fmt"
)

func main() {
	var res = [3]int{7, 5, 9}

	fmt.Println(res)
	i := 1
	j := 4
	fmt.Println(res[i])
	fmt.Println(res[j])
}
[7 5 9]
5
panic: runtime error: index out of range

goroutine 1 [running]:
main.main()
	/home/gabor/work/slides/golang/examples/array-index/array_index.go:14 +0x15b
exit status 2