Hi,
I just realized that I can turn any blocking function that returns type ABC into a non-blocking function that returns "<- chan ABC".
Many blocking functions block due to IO, and typically whereever there is IO there are errors. From my understanding, functions with errors should typically return (ABC, error). However, I can't transform such function into a function that returns "<- chan (ABC, error)", because channels are only able to deliver a single value. Thus, I need to create another struct that contains ABC and error fields. This is somewhat annoying (I've grown to like multi-variable returns).
Does anyone have any advice on how to proceed ? It seems like it would be fairly common to desire receipt of (result or error) via channel, but the language doesn't seem to help. Perhaps I'm missing something ?
Thanks,
ilyia