Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferedReader ¶
type BufferedReader struct {
// contains filtered or unexported fields
}
BufferedReader wraps an io.Reader with buffered line reading. This is the standard implementation used in production code.
func NewBufferedReader ¶
func NewBufferedReader(r io.Reader) *BufferedReader
NewBufferedReader creates a LineReader that reads from the given io.Reader.
func (*BufferedReader) ReadLine ¶
func (b *BufferedReader) ReadLine() (string, error)
ReadLine reads and returns the next line from the input.
type ErrorInjector ¶
type ErrorInjector struct {
// contains filtered or unexported fields
}
ErrorInjector wraps a LineReader and injects errors at specific points. Useful for testing error handling paths.
func NewErrorInjector ¶
func NewErrorInjector(reader LineReader, errorAt int, err error) *ErrorInjector
NewErrorInjector creates a LineReader that injects an error after reading a specific number of lines.
func (*ErrorInjector) ReadLine ¶
func (e *ErrorInjector) ReadLine() (string, error)
ReadLine delegates to the wrapped reader until the error point is reached.
type LineReader ¶
type LineReader interface {
// ReadLine returns the next line of input.
// Returns io.EOF when no more lines are available.
ReadLine() (string, error)
}
LineReader abstracts line-by-line reading for testability. This interface allows commands to process input without depending on concrete io.Reader implementations, enabling easy mocking and testing.
type SliceReader ¶
type SliceReader struct {
// contains filtered or unexported fields
}
SliceReader reads lines from a pre-defined slice. Useful for testing with known input sequences.
func NewSliceReader ¶
func NewSliceReader(lines []string) *SliceReader
NewSliceReader creates a LineReader from a slice of strings.
func (*SliceReader) ReadLine ¶
func (s *SliceReader) ReadLine() (string, error)
ReadLine returns the next line from the slice.