But sometimes it is useful to return both a value and a non-nil error. There might be partial results that you can still do things with despite hitting an error. Or the result value might be information that is useful with or without an error (like how Go's ubiquitous io.Writer interface returns the number of bytes written along with any error encountered).I appreciate that Go tends to avoid making limiting assumptions about what I might want to do with it (such as assuming I don't want to return a value whenever I return a non-nil error). I like that Go has simple, flexible primitives that I can assemble how I want.
gf000|2 months ago
Also, just let the use site pass in (out variable, pointer, mutable object, whatever your language has) something to store partial results.
Orygin|2 months ago
It's not a convention in Go, so it's not breaking any expectations
lock1|2 months ago