zstdzgo.at/zstd/zbyte Index | Files

package zbyte

import "zgo.at/zstd/zbyte"

Package zbyte implements functions for byte slices.

Index

Functions

func Binary

func Binary(b []byte) bool

Binary reports if this looks like binary data.

Something is considered binary if it contains a NULL byte in the first 8000 bytes.

This is the same check as git uses; see buffer_is_binary().

func ElideLeft

func ElideLeft(b []byte, n int) []byte

ElideLeft returns the "n" left bytes.

func ElideRight

func ElideRight(b []byte, n int) []byte

ElideRight returns the "n" right bytes.

func HasPrefixes

func HasPrefixes(b []byte, prefixes ...[]byte) bool

HasPrefixes tests whether the byte slice b starts with any of the prefixes.

Identical to:

bytes.HasPrefix(s, "one") || bytes.HasPrefix(s, "two")

func HasSuffixes

func HasSuffixes(b []byte, suffixes ...[]byte) bool

HasSuffixes tests whether the byte slice b ends with any of the suffixes.

Identical to:

bytes.HasSuffix(s, "one") || bytes.HasSuffix(s, "two")

func IndexAll

func IndexAll(s, find []byte) []int

IndexAll finds all occurrences of "find".

Source Files

zbyte.go

Version
v0.0.0-20240930202209-a63c3335042a (latest)
Published
Sep 30, 2024
Platform
linux/amd64
Imports
1 packages
Last checked
2 days ago

Tools for package owners.