zbytes

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInterfaceNotByte = errors.New("encountered non-byte interface")
)

Functions

func As

func As(slice []interface{}) (res []byte, err error)

Convert a []interface{} slice into []byte slice if possible

func Contains

func Contains(haystack []byte, needle byte) bool

Check if a slice ([]byte) contains a matching member

func ContainsAll

func ContainsAll(haystack []byte, needles ...byte) bool

Check if a []byte slice contains ALL of the provided members

func ContainsAny

func ContainsAny(haystack []byte, needles ...byte) bool

Check if a []byte slice contains ANY of the provided members

func Cut

func Cut(slice []byte, separator byte) (left, right []byte, found bool)

Cut the slice into two slices separated by the separator

func CutAny

func CutAny(val []byte, seperators ...byte) (left, right []byte, found bool)

Cut the slice into two slices separated by the first separator

func CutAt added in v0.9.1

func CutAt(val []byte, index int) (left, right []byte)

Cut the slice at the specified index

func Equal

func Equal(a []byte, b []byte) bool

Determine if two slices are equal to each other

func Fill

func Fill(slice []byte, val byte) []byte

Fill a slice with the given value

func Index

func Index(haystack []byte, needle byte) int

Find the index where the needle appears. Returns -1 if the needle doesn't appear in the slice.

func Interface

func Interface(slice []byte) (res []interface{}, err error)

Convert a []byte slice into a slice of interfaces ([]interface{})

func Remove

func Remove(slice []byte, offset int, values ...byte) (res []byte)

Remove the first occurrence of each value from the slice starting from the supplied offset

func RemoveAt

func RemoveAt(slice []byte, index int) (res []byte)

Remove the item at the index while preserving the order of the items TODO: maybe change this to take multiple indices and to remove them at the same time

func Resize

func Resize(s []byte, n int) (res []byte)

Resize a slice to the given length

func Sort

func Sort(s []byte)

Sort the slice in ascending order

func SortReverse

func SortReverse(s []byte)

Sort the slice in descending order

func Split

func Split(slice []byte, separator byte) (parts [][]byte)

Split the slice into one or more slices separated by the separator

Types

This section is empty.

Jump to

Keyboard shortcuts

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