Golang Microservices: Working and Dealing with Errors



Golang Microservices: Working and Dealing with Errors

Golang Microservices: Working and Dealing with Errors

In this video I share with you the approach I like to take and the best practices I follow when implementing domain errors in Go/Golang using the Hexagonal Architecture and writing idiomatic code:

* How to implement new errors
* How to deal with errors
* How to wrap errors
* How to define concrete codes to determine where errors come from

All of that using the new API introduced by Go 1.13:

* errors.Is
* errors.As
* errors.Unwrap

And the new verb added to the fmt package called %w.

This is the first of a series where I will cover more things related working with errors and dealing with failures where I’m planning to cover:
* Observability using OpenTelemetry
* Observability using NewRelic
* Resilience via Retries, Backoff algorithms and Circuit Breaking.

* Example code: https://github.com/MarioCarrion/todo-api-microservice-example/tree/acbed018c6abb716cd84dffc1777f91dfb5e3dfa
* Blog post: https://mariocarrion.com/2021/05/11/golang-microservices-handling-errors.html

* Previous episode: “Building Microservices in Golang: REST APIs – Versioning Techniques” https://youtu.be/4THy4iBQpFA
* Playlist “Golang/Go Tools and Packages”: https://www.youtube.com/playlist?list=PL7yAAGMOat_HEEOvH99agDs_5g51A0Ls3
* Playlist “Building Microservices in Go/Golang”: https://www.youtube.com/playlist?list=PL7yAAGMOat_Fn8sAXIk0WyBfK_sT1pohu
* Playlist “Golang/Go Testing”: https://www.youtube.com/playlist?list=PL7yAAGMOat_HSeW4zF0uRL9EaHadE4ZZq

00:00 Start
00:10 Agenda
00:40 Errors in Go 1.13
04:07 Other resources
06:23 Demo: project structure
07:34 Demo: implementing errors
08:23 Demo: errors in domain package
09:19 Demo: errors in PostgreSQL repository package
10:01 Demo: errors in service package
10:17 Demo: errors in rest package
11:27 Demo: connecting everything using swagger-ui
13:13 Demo: recap
14:30 Parting words

Who am I:

HelloπŸ‘‹πŸΌ! I’m Mario, a Hands-on Software Architect and Lead Backend Engineer with more than 16 years of professional experience building all kinds of software including on-premise Industrial Automation Systems, Linux Accessibility Desktop and Browser Components as well as Distributed Advertising Microservices.

Every week I will share with you different topics I’ve learned while working for small startups and large companies including the processes I’ve followed over the years for successfully delivering complex enterprise systems from start to end.

Subscribe if you like Software Development, Software Architecture and Systems Design!

Keep it up. Don’t give up!

#golang #microservices #errors

— Our affiliate links below

Shop our favorite products β†’ https://www.amazon.com/shop/rubycarrion
Vlogging setup β†’ https://rubycarrion.com/camerasforvlogging/
Shop now and save at BestBuy β†’ https://bestbuy.7tiv.net/2bB4g
DJI Osmo Action, Unleash Your Other Side β†’ https://click.dji.com/AIwI1huLYJ51YBmF82L_FQ?pm=link&as=0001&ch=rubycarriondjiosmoaction
Get a 30 day FREE trial of Epidemic Sound β†’ https://www.epidemicsound.com/referral/szx441/
Try Amazon Prime 30-Day FREE trial β†’ https://amzn.to/3s0el1R
I love getting Cash Back and think you will too! Join for free and get $20 when you spend $20 β†’ https://www.rakuten.com/r/RUBYRA132?eeid=28187
Sign up to start using vidIQ to grow your YouTube channel for FREE β†’ https://vidiq.com/rubycarrion

— Our Vlog Channel

https://www.youtube.com/c/RubyCarrion/videos

Comments are closed.