Function
first
(ctx context.Context, source <-chan interface{})
Source from the content-addressed store, hash-verified
| 31 | } |
| 32 | |
| 33 | func first(ctx context.Context, source <-chan interface{}) <-chan interface{} { |
| 34 | out := make(chan interface{}) |
| 35 | go func() { |
| 36 | defer close(out) |
| 37 | first := true |
| 38 | for val := range source { |
| 39 | if first { |
| 40 | if val != nil { |
| 41 | first = false |
| 42 | select { |
| 43 | case <-ctx.Done(): |
| 44 | return |
| 45 | case out <- val: |
| 46 | } |
| 47 | return |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | }() |
| 52 | return out |
| 53 | } |
| 54 | |
| 55 | func merge(ctx context.Context, cs ...chan interface{}) chan interface{} { |
| 56 | var wg sync.WaitGroup |
Tested by
no test coverage detected