This repository has been archived on 2024-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
2018-12-05 21:13:29 +08:00

23 lines
305 B
Go

package picker
import "context"
func SelectFast(ctx context.Context, in <-chan interface{}) <-chan interface{} {
out := make(chan interface{})
go func() {
select {
case p, open := <-in:
if open {
out <- p
}
case <-ctx.Done():
}
close(out)
for range in {
}
}()
return out
}