During first execution of the loop in the code snippet,an exception throws.my question is how to continue executing next iteration of the loop when panic happens.like try catch mechanism in java,the loop will continue executing next iteration of the loop.
package main
import (
"fmt"
)
func main() {
var arr []int = []int{5, 6, 7, 8, 9}
fmt.Println(arr)
for i := 6; i < 10; i++ {
defer func() {
fmt.Println("aaa")
if err := recover(); err != nil {
fmt.Printf("error is %v\n", err)
}
}()
arr[i] = i
}
}
arr