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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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