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

Tap

func (input *Channel[T]) Tap(function func(T), opts ...options.TapOption) *Channel[T]

Tap runs a function as a side effect for each input value, and then sends the input values transparently to the output channel. A common use case is logging.

Example

output := input.Tap(func(x int) { fmt.Println(x)})

Console output:
1
2
3