4 ms·
You could save the future in the Future implementation type future struct { completed bool result interface{} ch <-ch
by hornetblack 13y ago
You could save the future in the Future implementation
type future struct {
completed bool
result interface{}
ch <-chan interface{}
}
Edit: Or just check if the channel is closed
func (f *future) Wait() interface{} {
v, ok := <- ch
if ok { f.result = v; return v }
else { return f.result }
}