From fc925df147e5efaa137fc31ba4d82be8a6e8ee48 Mon Sep 17 00:00:00 2001 From: satboy78 Date: Wed, 5 Oct 2022 01:01:49 +0200 Subject: [PATCH] add error handling in go, defer, panic, recover (#2126) * add error handling in go, defer, panic, recover * Update content/roadmaps/109-golang/content/100-go-basics/106-errors-panic-recover.md * Update content/roadmaps/109-golang/content/100-go-basics/106-errors-panic-recover.md Co-authored-by: Matteo Bruno Co-authored-by: Kamran Ahmed --- .../100-go-basics/106-errors-panic-recover.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/content/roadmaps/109-golang/content/100-go-basics/106-errors-panic-recover.md b/content/roadmaps/109-golang/content/100-go-basics/106-errors-panic-recover.md index 1da9c2efb..a06864b21 100644 --- a/content/roadmaps/109-golang/content/100-go-basics/106-errors-panic-recover.md +++ b/content/roadmaps/109-golang/content/100-go-basics/106-errors-panic-recover.md @@ -1 +1,12 @@ -# Errors panic recover \ No newline at end of file +# Errors/Panic/Recover + +In lieu of adding exception handlers, the Go creators exploited Go’s ability to return multiple values. The most commonly used Go technique for issuing errors is to return the error as the last value in a return. + +A panic typically means something went unexpectedly wrong. Mostly used to fail fast on errors that shouldn’t occur during normal operation, or that we aren’t prepared to handle gracefully. + +Panic recovery in Go depends on a feature of the language called deferred functions. Go has the ability to guarantee the execution of a function at the moment its parent function returns. This happens regardless of whether the reason for the parent function’s return is a return statement, the end of the function block, or a panic. + +Free Content +Error handling and Go +Go Defer, Panic and Recover +Effective error handling in Go