v0.6.0 Latest Latest

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 4 Imported by: 0




This section is empty.


View Source
var ErrNoReader = errors.New("no input")

ErrNoReader is returned if there is no reader defined.


This section is empty.


type Conf

type Conf func(*MultiReader) error

Conf is used to configure the MultiReader.

func WithPaths

func WithPaths(paths []string, recursive bool) Conf

WithPaths searches through the path and adds any files it finds to the MultiReader. Each path will become its reader's name in the process. It returns an error if any of given files are not found. It ignores any files that cannot be read or opened.

func WithReader

func WithReader(name string, r io.ReadCloser) Conf

WithReader adds the {name,r} reader to the MultiReader. If name is empty, the key will not be written in the output. You can provide as many empty names as you need.

type MultiReader

type MultiReader struct {
	// contains filtered or unexported fields

MultiReader holds one or more io.ReadCloser and reads their contents when Read() method is called in order. The reader is loaded lazily if it is a file to prevent the system going out of file descriptors.

func NewMultiReader

func NewMultiReader(input ...Conf) (*MultiReader, error)

NewMultiReader creates an instance of the MultiReader and passes it to all input functions.

func (*MultiReader) Close

func (m *MultiReader) Close() error

Close does nothing.

func (*MultiReader) FileName added in v0.5.2

func (m *MultiReader) FileName() string

FileName returns the current reader's name.

func (*MultiReader) Read

func (m *MultiReader) Read(b []byte) (n int, err error)

Read is almost the exact implementation of io.MultiReader but keeps track of reader names. It closes each reader once they report they are exhausted, and it will happen on the next read.

Jump to

Keyboard shortcuts

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