Documentation
¶
Overview ¶
Package splitter provides a wrapper for creating a custom bufio.SplitFunc.
Reference:
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropCarriageReturn ¶
DropCarriageReturn drops the final byte of the slice if it is a carriage return.
Examples:
- DropCarriageReturn([]byte("abc\r")) == []byte("abc")
- DropCarriageReturn([]byte("abc")) == []byte("abc")
func ScanDocuments ¶ added in v0.0.10
ScanDocuments returns a function that splits a stream of bytes on the given separator byte slice and whether to drop line-ending carriage returns. Returns a new bufio.SplitFunc compatible with bufio.Scanner
Examples:
- ScanDocuments([]byte("---\n")[0], true) - split on YAML boundary marker and drop carriage returns at the end of a line.
func ScanLines ¶
ScanLines returns a function that splits a stream of bytes on the given separator character and whether to drop line-ending carriage returns. Returns a new bufio.SplitFunc compatible with bufio.Scanner
Examples:
- ScanLines([]byte("\n")[0], true) - split on new lines and drop carriage returns at the end of a line.
- ScanLines(byte(0), false) - split on null byte
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.