utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const FourSpaces = "    "

Variables

This section is empty.

Functions

func IsValidInput added in v0.7.0

func IsValidInput(data []byte) (isValidJSON bool, isValidJSONLines bool, err error)

IsValidInput checks the validity of input data as JSON or JSON lines. It takes a byte slice 'data' and returns two boolean values indicating whether the data is valid JSON and valid JSON lines, along with an error if the data is not valid in either format.

func IsValidJSON added in v0.7.0

func IsValidJSON(input []byte) error

func IsValidJSONLines added in v0.7.0

func IsValidJSONLines(input []byte) error

func Prettify added in v0.6.0

func Prettify(inputJSON []byte, chromaStyle *chroma.Style, isJSONLines bool) (*bytes.Buffer, error)

func ScanLinesWithDynamicBufferSize added in v0.7.0

func ScanLinesWithDynamicBufferSize(input []byte, maxBufferSize int, processLine func([]byte) error) error

ScanLinesWithDynamicBufferSize scans the input byte slice line by line, using a dynamically increasing buffer size. It starts with an initial buffer size of 64KB and doubles the buffer size each time a line exceeds the current buffer size, up to the specified maximum buffer size.

If a line exceeds the maximum buffer size, it returns an error.

The processLine function is called for each line and should return an error if processing fails.

The function returns an error if the input exceeds the maximum buffer size or if any other error occurs during line processing. It returns nil if all lines are processed successfully.

Types

This section is empty.

Jump to

Keyboard shortcuts

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