Overview When the panic is recovered then the return value of a panicking function will be the default value of the return types of the panicking function Program Let’s see a program for…
Category: Tech
Panic and Recover in Go (Golang)
This is the chapter 28 and also the last chapter of the golang comprehensive tutorial series. This is Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series…
Recover panic from goroutine in Go (Golang)
Overview There are two cases for recovering from a panic in a goroutine recover function in the same goroutine as panic recover function in a different goroutine as panic While in the…
Panic format string in Go (Golang)
Overview Below is the syntax of the panic function It takes empty interface as an argument. It does not provides any why to format the error string. However there is a workaround….
Defer a goroutine in Go (Golang)
Overview It is not directly possible to defer a goroutine. But there is a workaround. In the defer function you can call another function in a goroutine like below Example Let’s see…
Runtime Error Panic in Go (Golang)
Overview Runtime error in the program can happen in the below cases. All the below cases will also create a panic Out of bounds array access Calling a function on a nil…
Defer keyword in Go (Golang)
This is the chapter 14 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – PointerPrevious Tutorial – Switch Now let’s check…
Panic with Defer in Go (Golang)
Overview defer function will be executed even if panic happens in a program. In fact, defer function is the only function that is called after the panic. When the panic is raised in…
Recover a panic in a different function in Go (Golang)
Overview If the defer function and recover function is not called from the panicking function then it that case panic can also be recovered in the called function as well. In fact, it…
Error in Go (Golang)- Advanced
This is the chapter 27 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – Panic and RecoverPrevious Tutorial – Error –…