Accessing a slice or array element at an invalid index.
Go slices and arrays are bounds-checked at runtime. Attempting to access `s[i]` where `i < 0` or `i >= len(s)` triggers a runtime panic.
Off-by-one errors in `for` loops, assuming a slice returned from a search or split function has elements without checking `len(s) > 0`.
1package main2 3import "fmt"4 5func main() {6 items := []string{"apple", "banana"}7 fmt.Println(items[2]) // Panic: index out of range [2] with length 28}1package main2 3import "fmt"4 5func main() {6 items := []string{"apple", "banana"}7 index := 28 9 if index < len(items) {10 fmt.Println(items[index])11 } else {12 fmt.Println("Index out of range")13 }14}Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
`items` has length 2 (indices 0 and 1). Accessing `items[2]` exceeds the bounds of the underlying slice array.