channel

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package channel provides helper structs/methods/funcs for working with channels

Proxy from an io.Writer to a channel:

	w := channel.NewWriter(make(chan []byte, 10))
	go func() {
		w.Write([]byte("Hello, World"))
	}()

	fmt.Println(string(<-w.Chan()))
    w.Close()

Use of the constructor is required to initialize the channel. Provide a channel of sufficient size to handle messages from writer(s).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WriteCloser

type WriteCloser interface {
	io.WriteCloser
	Chan() <-chan []byte
}

WriteCloser is an io.WriteCloser that that proxies Write() calls to a channel The []byte buffer of the Write() is queued on the channel as one message.

func NewWriter

func NewWriter(c chan []byte) WriteCloser

NewWriter initializes a new channel writer

Jump to

Keyboard shortcuts

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