bytes

package
v1.2.117 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputePad

func ComputePad(s []byte, pad []byte, n int) (padCount, spaceCount int)

ComputePad returns pad's count and space's count(less than len(pad)) will be need to pad s to len n padCount = (n-len(s))/len(pad) spaceCount = (n-len(s))%len(pad)

func CountIndex

func CountIndex(s, sep []byte) (c, index int)

CountIndex counts the number of non-overlapping instances of sep in s. Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.

func NewIndent

func NewIndent(dst *bytes.Buffer, prefix, indent string, depth int)

func NewLine

func NewLine(dst *bytes.Buffer, prefix, indent string, depth int)

func PadLeft

func PadLeft(s []byte, pad []byte, n int) []byte

PadLeft returns s padded to length n, padded left with repeated pad return s directly if pad is empty padding s with {{pad}} and spaces(less than len(pad)) as a prefix, as [pad]...[pad][space]...[space][s]

func PadRight

func PadRight(s []byte, pad []byte, n int) []byte

PadRight returns s padded to length n, padded right with repeated pad return s directly if pad is empty padding s with {{pad}} and spaces(less than len(pad)) as a suffix, as [s][space]...[space][pad]...[pad]

func Reverse

func Reverse(s []byte) []byte

Reverse returns bytes in reverse order.

func Truncate

func Truncate(s []byte, n int) []byte

Truncate shrinks s's len to n at most

Types

This section is empty.

Jump to

Keyboard shortcuts

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