<- Back

Error handling in Go

07 June 2023

Ok, I have a confession to make. The first time I was introduced to error handling in Java using exceptions I was really excited. I could ignore any errors in my program and wrap the whole thing in a try-catch block. Any exception just print it out and deal with right?

Well that’s stupid and a naive way of thinking about errors. The thought only last a few minutes, honestly.

When I starting learning go, I absolutely loved the way Go does it from the outset. They don’t support the try catch method used by java. They are just values returned by functions and they are handled like any other value. It’s very simple, easy to understand and implement but there is a trade off.

A few years ago, the 2 biggiest issues people had with Go was a lack of Generics and it’s handling. Today Generics has been done rather well, Error handling. It’s not that it’s hard to do, it’s just that it’s verbose.

© Ackers 2023 v0.1.118
My thoughts and ramblings on this site, are my own