In Golang, panic without recovery will cause the process to crash, so at the beginning of each function, I insert the following code fragment:
defer func() { if err := recover(); err != nil { fmt.Println(err) } }()
just to prevent my program from crashing. Now I wonder if this is really the way to go? Because I think it's a little strange to put the same code everywhere.
It seems to me that the Java path that overlaps exceptions to the calling function is until the main function becomes the best way to manage exceptions / panic. I understand this from the Go design, but what is the advantage of an immediate process failure, like what Go does?
source share