pipe

package
v0.0.0-...-c269f4c Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pipe provides a wrapper to create a pipe and collect at most max bytes from the reader side

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPipe

func NewPipe(writer io.Writer, n int64) (<-chan struct{}, *os.File, error)

NewPipe create a pipe with a goroutine to copy its read-end to writer returns the write end and signal for finish caller need to close w

Types

type Buffer

type Buffer struct {
	W      *os.File
	Buffer *bytes.Buffer
	Done   <-chan struct{}
	Max    int64
}

Buffer is used to create a writable pipe and read at most max bytes to a buffer

func NewBuffer

func NewBuffer(max int64) (*Buffer, error)

NewBuffer creates a os pipe, caller need to caller need to close w Notice: if rely on done for finish, w need be closed in parent process

func (Buffer) String

func (b Buffer) String() string

Jump to

Keyboard shortcuts

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