Continuing with our lockdown learning of Go language. Here’s a video on panic in goroutines in Golang
A goroutine needs to have it’s own recover functions. Here’s the code that shows that
package main import ( "fmt" "time" ) func main() { go func() { defer func() { if r:=recover(); r != nil { fmt.Println("Error", r) } }() arr := [5]int{} //Something silly for i:=0; i< 15; i++ { fmt.Println(arr[i]) } }() time.Sleep(time.Second) fmt.Println("End of main") }
You can watch other videos in Go lang in the links below