splitter

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 2 Imported by: 0

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

func DropCarriageReturn(data []byte) []byte

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

func ScanDocuments(separator []byte, dropCR bool) bufio.SplitFunc

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

func ScanLines(separator byte, dropCR bool) bufio.SplitFunc

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.

Jump to

Keyboard shortcuts

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