(ctx context.Context, c <-chan A)
| 640 | } |
| 641 | |
| 642 | func RecvCtx[A any](ctx context.Context, c <-chan A) (a A, err error) { |
| 643 | select { |
| 644 | case <-ctx.Done(): |
| 645 | return a, ctx.Err() |
| 646 | case a, ok := <-c: |
| 647 | if ok { |
| 648 | return a, nil |
| 649 | } |
| 650 | return a, io.EOF |
| 651 | } |
| 652 | } |