For #3 you can also use errgroup from sync/errgroup. It's a nice recent addition to the stdlib.
For #4 wrapping your errors creates pretty and logical error messages for free. It should be done in most cases.
For #4 wrapping your errors creates pretty and logical error messages for free. It should be done in most cases.
There are two significant problems with the API:
An errgroup.WithContext today cancels the Context when its Wait method returns, which makes it easier to avoid leaking resources but somewhat prone to bugs involving accidental reuse of the Context after the call to Wait.
The need to call Wait in order to free resources makes errgroup.WithContext unfortunately still somewhat prone to leaks. If you start a bunch of goroutines and then encounter an error while setting up another one, it's easy to accidentally leak all of the goroutines started so far — along with their associated Context — by writing