Image from Renee french

This piece is focused on Handling Multiple Errors in Golang. We will be talking about simple ways to create a list of errors in Golang with a simple approach.

Usually, we used this function as a common handling error that we used. Each error will be returned after the function called.

In some cases, we need to pool the errors and handle them at the end of the function. Let’s try the library merr. The merr is a library to handle multiple errors in easy ways. It implements the native library interface errors that Go used.

In the above code, we can pool the error and handle it at the end of the code. The merr library support custom error string too. If you interest with the library you can access it on https://github.com/firdasafridi/merr.

See the documentation at https://pkg.go.dev/github.com/firdasafridi/merr.

Cheerss

--

--