News for hackers. Stuff that matters.
Re:Error handling with errgroups by TheDong on Friday October 29, 2021 @09:05PM (#29045138)
> The API has to be designed to support context cancellation, and most of the standard library is.

Important parts of the standard library are not designed for contexts. Let's say I want to write data to a file and then cancel that. How do I do that? `os.File.Write`, `io.Copy`, `ioutil.WriteFile`... none of these let me cancel a write.

The `io.Writer` interface not supporting contexts also means things like the compress and archive stdlib packages don't support contexts, among several others.

Most of the rest of it has had contexts bolted on in nonstandard ways. If you want to use contexts, you can no longer use "net.Dial" or "net.DialTimeout", but must instead use the awkward "(&net.Dialer{}).DialContext" method. The http package has similar issues, including non-idiomatic context usage.

The go stdlib was mostly built before contexts existed, has promised backwards compatibility, and it really shows.

Re:Error handling with errgroups by kubb on Saturday October 30, 2021 @03:58AM (#29046937)
Good points!