Receive returns the value received on the underlying channel, or the error returned by ctx if it is closed or cancelled.
(ctx context.Context)
| 84 | // Receive returns the value received on the underlying channel, or the error |
| 85 | // returned by ctx if it is closed or cancelled. |
| 86 | func (c *Channel) Receive(ctx context.Context) (any, error) { |
| 87 | select { |
| 88 | case <-ctx.Done(): |
| 89 | return nil, ctx.Err() |
| 90 | case got := <-c.C: |
| 91 | return got, nil |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Replace clears the value on the underlying channel, and sends the new value. |
| 96 | // |