tee

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 0 Imported by: 0

README

Tee

Tee API implements a concurrency pattern, where an input from a singular channel is copied into two channels. In conpats, Tee is generalized and copies values into an n number of channels (buffered or unbuffered).

Usage

Simply use tee.NewTee(...):

in := make(chan int)

// create 3 unbuffered channels
outs := tee.NewTee(in, 3, 0)

Returned channels can be unbuffered or buffered. Specify that using the last argument in the tee.NewTee(...) function:

in := make(chan int)

// create 5 buffered channels with buffer size 10
outs := tee.NewTee(in, 5, 10)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTee

func NewTee[I any](in <-chan I, n int, buf int) []chan I

NewTee takes an input channel and returns n output channels that each receive all items from the input channel.

A buffer size can be specified for the output channels; if buf is 0 or negative, unbuffered channels are created.

Types

This section is empty.

Jump to

Keyboard shortcuts

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