Skip to main content Link Search Menu Expand Document (external link)

Filter

func (input *Channel[T]) Filter(predicate func(T) bool, opts ...options.FilterOption) *Channel[T]

Filter sends to the output channel only the input values that match the predicate function.

Example

output := input.Filter(func(x int) bool { return x%2 == 1 })