Re:Things from Python I'd miss in Go
by zimbatm on Tuesday June 10, 2014 @09:54AM
(#7872446)
The readConfig example is not really an issue in go. Just return the io error and type switch after the readConfig.
[ Parent
| on HN ]
> Just return the io error
Manually, on every function call that may fail - that was my only point why exceptions may result in a clearer code.
section, err := parseSection(ioReader)
if err != nil { return nil, err }
Has some boilerplate, as compared to a typical exception-based section = parseSection(reader) // throws IOErrorYeah I get what you mean.
If you forget that "throws" comment then the Java code is opaque to the exception. I think Go developer see a value in having errors exposed explicitly, it forces them to think about how to handle them instead of having a catch-all at the top of the program. But now we're down to philosophy and personal taste :)