mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-10-30 00:48:15 +00:00
22 lines
305 B
Go
22 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
|
|
}
|