Golang Function Timeout With Context

Timeouts can be important for an application. It can limit how long is the maximum duration of a process. We can save resources by cancel further processes when timeout happened. We can use context to apply a timeout to a function call in Go.

[Read More]

Handle Panic in HTTP Server by Using Middleware in Go

If you have code in Go, most likely you have ever encountered a panic. Panic can stop your application if it is not recovered. Fortunately, in the Go HTTP server, there is already a panic recovery, so the server will continue to run if panic is encountered. But the client will not get any response from the server if a panic happens. It is good that you have your own panic recovery that responds with an error message.

[Read More]