Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Codec encoding.Encoding BufferSize int Terminator LineTerminator MaxBytes int }
Config stores the configuration for the readers required to read a file line by line
type EncoderReader ¶
type EncoderReader struct {
// contains filtered or unexported fields
}
Reader produces lines by reading lines from an io.Reader through a decoder converting the reader it's encoding to utf-8.
func NewEncodeReader ¶
func NewEncodeReader(r io.ReadCloser, config Config) (EncoderReader, error)
New creates a new Encode reader from input reader by applying the given codec.
func (EncoderReader) Close ¶
func (r EncoderReader) Close() error
type FileMetaReader ¶
type FileMetaReader struct {
// contains filtered or unexported fields
}
Reader produces lines by reading lines from an io.Reader through a decoder converting the reader it's encoding to utf-8.
func (*FileMetaReader) Close ¶
func (r *FileMetaReader) Close() error
type LimitReader ¶
type LimitReader struct {
// contains filtered or unexported fields
}
Reader sets an upper limited on line length. Lines longer then the max configured line length will be snapped short.
func NewLimitReader ¶
func NewLimitReader(r reader.Reader, maxBytes int) *LimitReader
New creates a new reader limiting the line length.
func (*LimitReader) Close ¶
func (r *LimitReader) Close() error
type LineReader ¶
type LineReader struct {
// contains filtered or unexported fields
}
LineReader reads lines from underlying reader, decoding the input stream using the configured codec. The reader keeps track of bytes consumed from raw input stream for every decoded line.
func NewLineReader ¶
func NewLineReader(input io.ReadCloser, config Config) (*LineReader, error)
NewLineReader creates a new reader object
func (*LineReader) Close ¶
func (r *LineReader) Close() error
func (*LineReader) Next ¶
func (r *LineReader) Next() (b []byte, n int, err error)
Next reads the next line until the new line character. The return value b is the byte slice that contains the next line. The return value n is the number of bytes that were consumed from the underlying reader to read the next line. If the LineReader is configured with maxBytes n may be larger than the length of b due to skipped lines.
type LineTerminator ¶
type LineTerminator uint8
LineTerminator is the option storing the line terminator characters Supported newline reference: https://en.wikipedia.org/wiki/Newline#Unicode
const ( // InvalidTerminator is the invalid terminator InvalidTerminator LineTerminator = iota // AutoLineTerminator accepts both LF and CR+LF AutoLineTerminator // LineFeed is the unicode char LF LineFeed // VerticalTab is the unicode char VT VerticalTab // FormFeed is the unicode char FF FormFeed // CarriageReturn is the unicode char CR CarriageReturn // CarriageReturnLineFeed is the unicode chars CR+LF CarriageReturnLineFeed // NextLine is the unicode char NEL NextLine // LineSeparator is the unicode char LS LineSeparator // ParagraphSeparator is the unicode char PS ParagraphSeparator // NullTerminator NullTerminator )
func (*LineTerminator) Unpack ¶
func (l *LineTerminator) Unpack(option string) error
Unpack unpacks the configuration from the config file
type StripNewline ¶
type StripNewline struct {
// contains filtered or unexported fields
}
StripNewline reader removes the last trailing newline characters from read lines.
func NewStripNewline ¶
func NewStripNewline(r reader.Reader, terminator LineTerminator) *StripNewline
New creates a new line reader stripping the last tailing newline.
func (*StripNewline) Close ¶
func (p *StripNewline) Close() error
type TimeoutReader ¶
type TimeoutReader struct {
// contains filtered or unexported fields
}
TimeoutReader will signal some configurable timeout error if no new line can be returned in time.
func NewTimeoutReader ¶
NewTimeoutReader returns a new timeout reader from an input line reader.
func (*TimeoutReader) Close ¶
func (r *TimeoutReader) Close() error
func (*TimeoutReader) Next ¶
func (r *TimeoutReader) Next() (reader.Message, error)
Next returns the next line. If no line was returned before timeout, the configured timeout error is returned. For handline timeouts a goroutine is started for reading lines from configured line reader. Only when underlying reader returns an error, the goroutine will be finished.