Documentation ¶
Index ¶
- func ScanStxEtxCombiRecord(data []byte, atEOF bool) (advance int, token []byte, err error)
- func ScanStxEtxRecord(data []byte, atEOF bool) (advance int, token []byte, err error)
- type LineWriter
- type Reader
- func (a Reader) Decompress() Reader
- func (a Reader) DecompressIf(p bool) Reader
- func (a Reader) ForEach(splitFunc bufio.SplitFunc, handler ReaderHandler) Reader
- func (a Reader) ForEachLine(handler ReaderHandler) Reader
- func (a Reader) ForEachRecord(handler ReaderHandler) Reader
- func (a Reader) FromBytes(b []byte) error
- func (a Reader) Gob(e any) Reader
- func (a Reader) Json(e any) Reader
- func (a Reader) Open(filename string) error
- func (a Reader) Read(r io.Reader) error
- func (a Reader) Then(b Reader) Reader
- func (a Reader) Xml(e any) Reader
- func (a Reader) Yaml(e any) Reader
- type ReaderHandler
- type Writer
- func (a Writer) Compress() Writer
- func (a Writer) CompressIf(p bool) Writer
- func (a Writer) CreateBytes() ([]byte, error)
- func (a Writer) CreateFile(filename string) error
- func (a Writer) Gob(e any) Writer
- func (a Writer) Then(b Writer) Writer
- func (a Writer) Write(w io.Writer) error
- func (a Writer) WriteLines(w WriterHandler) Writer
- func (a Writer) WriteRecords(w WriterHandler) Writer
- type WriterHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScanStxEtxCombiRecord ¶
ScanStxEtxCombiRecord is a bufio.SplitFunc which can handle a mix of plain lines and STX-ETX records. This is used instead of ScanStxEtcRecord or bufio.ScanLines if the content can be mixed.
e.g. a log file was originally plain lines then changed to STX-ETX record format.
The tokens
Types ¶
type LineWriter ¶
type Reader ¶
func (Reader) Decompress ¶
func (Reader) DecompressIf ¶
func (Reader) ForEach ¶
func (a Reader) ForEach(splitFunc bufio.SplitFunc, handler ReaderHandler) Reader
ForEach will call a ReaderHandler function for each token returned by a bufio.Scanner running over the file. The scanner will use the supplied bufio.SplitFunc to determine the token's passed to the ReaderHandler.
func (Reader) ForEachLine ¶
func (a Reader) ForEachLine(handler ReaderHandler) Reader
ForEachLine will call a ReaderHandler function for each lf or crlf terminated line from the file.
This is shorthand for Reader.ForEach(bufio.ScanLines, handler)
func (Reader) ForEachRecord ¶
func (a Reader) ForEachRecord(handler ReaderHandler) Reader
ForEachRecord will call a ReaderHandler function for each STX-ETX delimited record from the file.
This is shorthand for Reader.ForEach(ScanStxEtxRecord, handler)
type ReaderHandler ¶
ReaderHandler accepts a line or record from a Reader
type Writer ¶
Writer writes data to an io.Writer
func (Writer) CompressIf ¶
func (Writer) CreateBytes ¶
func (Writer) CreateFile ¶
CreateFile creates a file using the writer
func (Writer) WriteLines ¶
func (a Writer) WriteLines(w WriterHandler) Writer
WriteLines will call a WriterHandler and each line written to the handler will be terminated with a Line Feed.
func (Writer) WriteRecords ¶
func (a Writer) WriteRecords(w WriterHandler) Writer
WriteRecords will call a WriterHandler and each line written to the handler will be wrapped with a stx/etx pair.
type WriterHandler ¶
type WriterHandler func(w LineWriter) error
WriterHandler is a function called by WriteLines when writing Lines or WriteRecords when writing Records