mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
1.0 KiB
1.0 KiB
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| SeqToChannel | seqtochannel | it/channel.go#L12 | it | channel |
|
https://go.dev/play/p/id3jqJPffT6 |
|
|
0 |
Converts an iter.Seq (or iter.Seq2) into a read-only channel. Items are sent on a buffered channel and the channel is closed when the sequence ends.
Examples:
// SeqToChannel: stream ints from a sequence
seq := it.Range(5) // 0..4
ch := it.SeqToChannel(2, seq)
var got []int
for v := range ch {
got = append(got, v)
}
// got == []int{0, 1, 2, 3, 4}
// SeqToChannel2: stream key/value pairs as Tuple2
m := map[string]int{"a": 1, "b": 2}
kv := it.Entries(m)
ch := it.SeqToChannel2(1, kv)
for pair := range ch {
// pair.A is key, pair.B is value
}