go1.20.5
GoThrough

bytes.MinRead

// MinRead is the minimum slice size passed to a Read call by // Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond // what is required to hold the contents of r, ReadFrom will not grow the // underlying buffer. const MinRead = 512

bytes.ErrTooLarge

// ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer. var ErrTooLarge = errors.New("bytes.Buffer: too large")

bytes.Clone

// Clone returns a copy of b[:len(b)]. // The result may have additional unused capacity. // Clone(nil) returns nil. func Clone(b []byte) []byte

bytes.Compare

// Compare returns an integer comparing two byte slices lexicographically. // The result will be 0 if a == b, -1 if a < b, and +1 if a > b. // A nil argument is equivalent to an empty slice. func Compare(a []byte, b []byte) int

bytes.Contains

// Contains reports whether subslice is within b. func Contains(b []byte, subslice []byte) bool

bytes.ContainsAny

// ContainsAny reports whether any of the UTF-8-encoded code points in chars are within b. func ContainsAny(b []byte, chars string) bool

bytes.ContainsRune

// ContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b. func ContainsRune(b []byte, r rune) bool

bytes.Count

// Count counts the number of non-overlapping instances of sep in s. // If sep is an empty slice, Count returns 1 + the number of UTF-8-encoded code points in s. func Count(s []byte, sep []byte) int

bytes.Cut

// Cut slices s around the first instance of sep, // returning the text before and after sep. // The found result reports whether sep appears in s. // If sep does not appear in s, cut returns s, nil, false. // // Cut returns slices of the original slice s, not copies. func Cut(s []byte, sep []byte) (before []byte, after []byte, found bool)

bytes.CutPrefix

// CutPrefix returns s without the provided leading prefix byte slice // and reports whether it found the prefix. // If s doesn't start with prefix, CutPrefix returns s, false. // If prefix is the empty byte slice, CutPrefix returns s, true. // // CutPrefix returns slices of the original slice s, not copies. func CutPrefix(s []byte, prefix []byte) (after []byte, found bool)

bytes.CutSuffix

// CutSuffix returns s without the provided ending suffix byte slice // and reports whether it found the suffix. // If s doesn't end with suffix, CutSuffix returns s, false. // If suffix is the empty byte slice, CutSuffix returns s, true. // // CutSuffix returns slices of the original slice s, not copies. func CutSuffix(s []byte, suffix []byte) (before []byte, found bool)

bytes.Equal

// Equal reports whether a and b // are the same length and contain the same bytes. // A nil argument is equivalent to an empty slice. func Equal(a []byte, b []byte) bool

bytes.EqualFold

// EqualFold reports whether s and t, interpreted as UTF-8 strings, // are equal under simple Unicode case-folding, which is a more general // form of case-insensitivity. func EqualFold(s []byte, t []byte) bool

bytes.Fields

// Fields interprets s as a sequence of UTF-8-encoded code points. // It splits the slice s around each instance of one or more consecutive white space // characters, as defined by unicode.IsSpace, returning a slice of subslices of s or an // empty slice if s contains only white space. func Fields(s []byte) [][]byte

bytes.FieldsFunc

// FieldsFunc interprets s as a sequence of UTF-8-encoded code points. // It splits the slice s at each run of code points c satisfying f(c) and // returns a slice of subslices of s. If all code points in s satisfy f(c), or // len(s) == 0, an empty slice is returned. // // FieldsFunc makes no guarantees about the order in which it calls f(c) // and assumes that f always returns the same value for a given c. func FieldsFunc(s []byte, f func(rune) bool) [][]byte

bytes.HasPrefix

// HasPrefix tests whether the byte slice s begins with prefix. func HasPrefix(s []byte, prefix []byte) bool

bytes.HasSuffix

// HasSuffix tests whether the byte slice s ends with suffix. func HasSuffix(s []byte, suffix []byte) bool

bytes.Index

// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s. func Index(s []byte, sep []byte) int

bytes.IndexAny

// IndexAny interprets s as a sequence of UTF-8-encoded Unicode code points. // It returns the byte index of the first occurrence in s of any of the Unicode // code points in chars. It returns -1 if chars is empty or if there is no code // point in common. func IndexAny(s []byte, chars string) int

bytes.IndexByte

// IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b. func IndexByte(b []byte, c byte) int

bytes.IndexFunc

// IndexFunc interprets s as a sequence of UTF-8-encoded code points. // It returns the byte index in s of the first Unicode // code point satisfying f(c), or -1 if none do. func IndexFunc(s []byte, f func(r rune) bool) int

bytes.IndexRune

// IndexRune interprets s as a sequence of UTF-8-encoded code points. // It returns the byte index of the first occurrence in s of the given rune. // It returns -1 if rune is not present in s. // If r is utf8.RuneError, it returns the first instance of any // invalid UTF-8 byte sequence. func IndexRune(s []byte, r rune) int

bytes.Join

// Join concatenates the elements of s to create a new byte slice. The separator // sep is placed between elements in the resulting slice. func Join(s [][]byte, sep []byte) []byte

bytes.LastIndex

// LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s. func LastIndex(s []byte, sep []byte) int

bytes.LastIndexAny

// LastIndexAny interprets s as a sequence of UTF-8-encoded Unicode code // points. It returns the byte index of the last occurrence in s of any of // the Unicode code points in chars. It returns -1 if chars is empty or if // there is no code point in common. func LastIndexAny(s []byte, chars string) int

bytes.LastIndexByte

// LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s. func LastIndexByte(s []byte, c byte) int

bytes.LastIndexFunc

// LastIndexFunc interprets s as a sequence of UTF-8-encoded code points. // It returns the byte index in s of the last Unicode // code point satisfying f(c), or -1 if none do. func LastIndexFunc(s []byte, f func(r rune) bool) int

bytes.Map

// Map returns a copy of the byte slice s with all its characters modified // according to the mapping function. If mapping returns a negative value, the character is // dropped from the byte slice with no replacement. The characters in s and the // output are interpreted as UTF-8-encoded code points. func Map(mapping func(r rune) rune, s []byte) []byte

bytes.NewBuffer

// NewBuffer creates and initializes a new Buffer using buf as its // initial contents. The new Buffer takes ownership of buf, and the // caller should not use buf after this call. NewBuffer is intended to // prepare a Buffer to read existing data. It can also be used to set // the initial size of the internal buffer for writing. To do that, // buf should have the desired capacity but a length of zero. // // In most cases, new(Buffer) (or just declaring a Buffer variable) is // sufficient to initialize a Buffer. func NewBuffer(buf []byte) *Buffer

bytes.NewBufferString

// NewBufferString creates and initializes a new Buffer using string s as its // initial contents. It is intended to prepare a buffer to read an existing // string. // // In most cases, new(Buffer) (or just declaring a Buffer variable) is // sufficient to initialize a Buffer. func NewBufferString(s string) *Buffer

bytes.NewReader

// NewReader returns a new Reader reading from b. func NewReader(b []byte) *Reader

bytes.Repeat

// Repeat returns a new byte slice consisting of count copies of b. // // It panics if count is negative or if the result of (len(b) * count) // overflows. func Repeat(b []byte, count int) []byte