channel

package
v0.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 1 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Beep added in v0.19.0

func Beep[T any](in <-chan T) <-chan T

Beep is a simple channel that dumps all of its input to the console. It can be used to debug a channel's contents without disrupting the flow of data.

func Closed

func Closed[T any](channel <-chan T) bool

Closed returns TRUE if this channel is closed, and FALSE otherwise. It does not read from the channel, and is just a simple wrapper around a select statement.

func Filter added in v0.19.1

func Filter[T any](input <-chan T, predicate Predicate[T]) <-chan T

Filter returns a channel that contains only the items that pass the predicate function.

func FromSlice added in v0.19.1

func FromSlice[T any](slice []T) <-chan T

FromSlice posts every item from a slice to a channel, and then closes the channel.

func Limit

func Limit[T any](maximum int, input <-chan T, done chan<- struct{}) <-chan T

Limit returns a channel that will receive at most the specified number of items from the input channel. When the maximum is reached, Limit will close the "done" channel, to communicate to other goroutines that they can stop sending items.

func Map added in v0.19.0

func Map[Input any, Output any](input <-chan Input, mapper func(Input) Output) <-chan Output

Map applies a mapping function to every value in the input channel, passing the mapped values out to the output channel.

func Pipe

func Pipe[T any](input <-chan T, output chan<- T)

Pipe reads the contents of one channel directly into another channel.

func PipeWithCancel

func PipeWithCancel[T any](input <-chan T, output chan<- T, done <-chan struct{})

PipeWithCancel reads the contents of one channel directly into another channel. If the "done" channel is closed, the pipe will stop.

func Reverse

func Reverse[T any](input <-chan T) <-chan T

Reverse reads an entire channel into a stack, then writes it back out in reverse order Since it keeps the entire channel in memory, it should not be used for unbounded data sets

func Slice

func Slice[T any](channel <-chan T) []T

Slice returns a slice of all items in a channel.

Types

type Done added in v0.19.1

type Done chan struct{}

Done is just sugar around a standard channel type that identifies that a process has completed

type Predicate added in v0.19.1

type Predicate[T any] func(T) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL