How to EFFICIENTLY Handle Errors in Golang APIs

preview_player
Показать описание

In this video will show how you can handle errors in your Golang APIs while being pragmatic and as practical as possible, so you can focus in what really matters: building stuff.

📢 We're building a Discord community, come and join

#golang #go #api
Рекомендации по теме
Комментарии
Автор

Thanks Tiago
I had some confusion
video is super helpful thanks
Keep up the good work

prashlovessamosa
Автор

Please make an fullstack application using go. Thank for this.

samsrec
Автор

One thing that I wanted to mention regarding the "other solution"

When you are saying that the method where you return errors directly from the handler and wrapping a middleware around it does not make sense and the reasoning behind that is the custom error codes and error messages. You can do the following, create a struct like APIError for example and implement an Error method for it, it would act as an error and that struct would have the original error, message and status code inside it (whatever data you would need) and basically inside the middleware you'll just do the json encoding of that struct and thats it. You essentially achieve the same thing with the fewer lines of code inside the handler, and I personally think it is better approach then doing writejson with return on every code block.

David-xynw
Автор

Great video,
Can you like create a video on deploying golang apis

AllAboutCode