Help us shape the future of Go! Take the 2026 Go Developer Survey

clireader

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 3 Imported by: 0

README

cli-reader

Go Reference

Provides an io.Reader intended to simulate newline delimited input from the command line.

Might be useful in testing CLI apps?

Documentation

Overview

Package clireader provides an io.Reader intended to simulate newline delimited input from the command line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader implements an io.Reader intended to simulate newline delimited input from the command line. A Reader is constructed by providing a list of strings. Each call to Read will return a string from the provided list, in order, with a newline appended, along with an error value of io.EOF to signal the end of the current input. Once all strings have been read, calling Read stops reading bytes and returns (0, io.EOF) to signal that the reader has been exhausted.

func New

func New(inputs ...string) *Reader

New returns a *Reader configured to return a string from the provided list, in order, with a newline appended, for each call to Read.

func (*Reader) Read

func (reader *Reader) Read(buf []byte) (int, error)

Read copies up to len(buf) bytes from the Reader into buf, and returns the number of bytes copied along with any error.

If the number of bytes returned is greater than 0, and the returned error is nil, there are more bytes to be read from the current input.

If the number of bytes returned is greater than 0, and the returned error is io.EOF the current input is complete, and the reader will be advanced to the next input.

If the number of bytes returned is 0, and the returned error is io.EOF, the reader has been exhausted.

Jump to

Keyboard shortcuts

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