3 ms·
The author seems not to be aware, that there is a "better" version of fmt.Errorf using %w instead of %v since go 1.13. Which allows to unwrap nested errors by
by LordHeini 6y ago
The author seems not to be aware, that there is a "better" version of fmt.Errorf using %w instead of %v since go 1.13.
Which allows to unwrap nested errors by their type.
Doing it the stringly way often forces one to do string compare on the errors message. Which obviously is just bad.
In general the go error handling is plainly awful.
A common problem is, that functions always return something besides the error, which may or may be not a null pointer or random crap.
So one is free to ignore the error and then do other stuff with the return (like a later null check which might rely on undocumented behavior)
I really do not get it. Go has implicit interfaces but yet the most verbose and impractical error handling ever.
Implicits like Scala! Making all the "go is explicit because it makes it easy to reason about and thus verbose error handling" arguments invalid.
Union types are a way better way to do proper error handling as proven by countless programming languages like rust and all the functional ones.