|
|
|
|
|
by Kamq
702 days ago
|
|
Yeah, go's a little boilerplatey, but you have to option to run two sync things concurrently as well with something like: type result[T any] struct {
el T
err error
}
chanA := make(chan result[aResultType])
chanB := make(chan result[bResultType])
go func() {
defer close(chanA)
a := &blah{}
rA, err := engine.doSomethingWithA()
chanA <- result[aResultType]{
el: rA,
err: err,
}
}()
go func() {
defer close(chanB)
b := &bloop{}
rB, err := engine.doSomethingWithB()
chanB <- result[bResultType]{
el: rB,
err: err,
}
}
resultA := <- chanA
resultB := <- chanB
|
|