wip: close chan

This commit is contained in:
Kevin Franklin Kim 2025-05-12 23:17:08 +02:00
parent e268779e11
commit 3d9da4ba7a
No known key found for this signature in database

11
go.go
View File

@ -145,13 +145,13 @@ func Go(fn Func, opts ...Option) <-chan error {
} }
} }
errChan := make(chan error) errChan := make(chan error, 1)
go func(o *Options, errChan chan<- error) { go func(o *Options, errChan chan<- error) {
var err error var err error
defer func() { defer func() {
o.l.Info("gofuncy --> closing chan") o.l.Info("gofuncy --> closing chan")
close(errChan) close(errChan)
o.l.Info("gofuncy --> closing chan done") o.l.Info("gofuncy --> closing chan")
}() }()
ctx := o.ctx ctx := o.ctx
start := time.Now() start := time.Now()
@ -187,11 +187,12 @@ func Go(fn Func, opts ...Option) <-chan error {
} }
ctx = injectParentRoutineIntoContext(ctx, RoutineFromContext(ctx)) ctx = injectParentRoutineIntoContext(ctx, RoutineFromContext(ctx))
ctx = injectRoutineIntoContext(ctx, o.name) ctx = injectRoutineIntoContext(ctx, o.name)
o.l.Info("gofuncy --> calling") l.Info("gofuncy --> calling")
err = fn(ctx) err = fn(ctx)
o.l.Info("gofuncy --> done") l.Info("gofuncy --> done")
defer o.l.Info("gofuncy --> out") defer l.Info("gofuncy --> out")
errChan <- err errChan <- err
l.Info("gofuncy <-- done")
}(o, errChan) }(o, errChan)
o.l.Info("gofuncy --> returning") o.l.Info("gofuncy --> returning")