I built a package that allows to create groups of goroutines on program start and then shut them down in the reverse creation order, group by group. This is very handy to make sure program shuts down cleanly, waiting for all goroutines to finish.
Please have a look at the code https://github.com/ash2k/stager
I've used it in quite a few projects over the years and I thought maybe it'll be useful to the community too. I propose to include it as a package in https://github.com/golang/sync/ repository.
shut them down in the reverse creation order [...] waiting for all goroutines to finish
I imagine you could accomplish the same via defers and a synchronization method like a waitgroup, so it's unclear to me that this is truly needed in x/sync. It's entirely fine for people to use the third party package if they so desire. See https://golang.org/doc/faq#x_in_std.
Ok, no worries. I just see that errgroup is there and it's even simpler than what I'm suggesting. 馃し
Most helpful comment
I imagine you could accomplish the same via defers and a synchronization method like a waitgroup, so it's unclear to me that this is truly needed in
x/sync. It's entirely fine for people to use the third party package if they so desire. See https://golang.org/doc/faq#x_in_std.