trim

package
v0.156.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Leading

func Leading(data []byte) []byte

func Nop

func Nop(token []byte) []byte

func ToLength added in v0.87.0

func ToLength(splitFunc bufio.SplitFunc, maxLength int) bufio.SplitFunc

func ToLengthWithTruncate added in v0.149.0

func ToLengthWithTruncate(splitFunc bufio.SplitFunc, maxLength int, skipping *bool) bufio.SplitFunc

ToLengthWithTruncate wraps a bufio.SplitFunc to truncate tokens that exceed maxLength. Unlike ToLength which splits oversized content into multiple tokens, this function returns only the truncated portion (up to maxLength) and advances past the entire original content, effectively dropping the remainder. The skipping parameter is a pointer to a bool that tracks whether we're currently skipping the remainder of an oversized entry. This allows the state to be persisted across multiple reader recreations (e.g., between poll cycles).

func Trailing

func Trailing(data []byte) []byte

func Whitespace

func Whitespace(data []byte) []byte

func WithFunc added in v0.86.0

func WithFunc(splitFunc bufio.SplitFunc, trimFunc Func) bufio.SplitFunc

Types

type Config

type Config struct {
	PreserveLeading  bool `mapstructure:"preserve_leading_whitespaces,omitempty"`
	PreserveTrailing bool `mapstructure:"preserve_trailing_whitespaces,omitempty"`
}

func (Config) Func

func (c Config) Func() Func

type Func

type Func func([]byte) []byte

Jump to

Keyboard shortcuts

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