Tag: Go

golang and recover

Go’s panic() function is great, it allows you to cause the entire program to exit if there is an error, much like exceptions in another languages, except that Go will print out useful information about your current goroutines. On top of that, when panicking begins, all of your deferred functions are also called, allowing you to tidy up any resources before the program exits. I used to think this was great already, but then I stumbled upon the recover() function when looking through the net package’s source code.