This post explores different approaches to error handling in Go, starting with the basic 'if err != nil' approach and moving on to wrapped errors, descriptive errors, and error sentinels. It also discusses the problems with each approach and provides examples of how to implement them in Go code.
Table of contents
Conquering Errors in Go: A Guide to Returning and Handling errorsLevel 1: if err != nilLevel 2: Wrapped ErrorsLevel 3: Descriptive ErrorsLevel 4: Error SentinelsBonus: Where to Log errors3 Comments
Sort: