Back to Lo

Core Slicetochannel

docs/data/core-slicetochannel.md

1.53.0220 B
Original Source

SliceToChannel converts a slice to a channel with specified buffer size.

go
items := []int{1, 2, 3, 4, 5}
ch := lo.SliceToChannel(10, items)

for item := range ch {
    fmt.Println(item)
}
// Prints 1, 2, 3, 4, 5