Skip to content

Coding standards

kstola2 edited this page Jun 22, 2019 · 5 revisions

Errors

Returning custom errors from your functions is a way of identifying the root of undesired behaviour. If there is a case in your function that checks for errors, make sure to return it with the following format:

if err != nil {
    errors.New("Failed to do the thing:\n%v", err)
}

This will allow us to build our own stack trace which is great for debugging.

Clone this wiki locally