I have the code as below and defer wasn't executed.
Doesn't defer work if we put it after panic?
package main
import (
"fmt"
)
func main() {
fmt.Println("begining of main")
panic("stop here")
defer fmt.Println("end of main")
}
nghiatran@nghiatran-VB:~/go/src/defer$ go run main.go
begining of main
panic: stop here
goroutine 1 [running]:
main.main()
/home/nghiatran/go/src/defer/main.go:9 +0x96
exit status 2
nghiatran@nghiatran-VB:~/go/src/defer$