What are your thoughts on adding support for getting errors back and thereby also handling panics, e.g.,
// RunErr runs a function of type func() error in a new goroutine.
// The returned channel is closed when f returns.
func (r *Runner) RunErr(f func() error) <-chan error {
done := make(chan error, 1)
r.wg.Add(1)
go func() {
var ret error
defer func() {
rec := recover()
if recErr, ok := rec.(error); ok {
ret = recErr
} else if rec != nil {
ret = errors.New(fmt.Sprintf("panic: %+v", rec))
}
done <- ret
close(done)
r.wg.Done()
}()
ret = f()
}()
return done
}
(and also RunErrContext and RunErrOtherContext)
What are your thoughts on adding support for getting errors back and thereby also handling panics, e.g.,
(and also
RunErrContextandRunErrOtherContext)