3// license that can be found in the LICENSE file.
4
5▶// Package bytes implements functions for the manipulation of byte slices.
6// It is analogous to the facilities of the [strings] package.
7package bytes
· · ·
19// are the same length and contain the same bytes.
20// A nil argument is equivalent to an empty slice.
21▶func Equal(a, b []byte) bool {
22 // Neither cmd/compile nor gccgo allocates for these string conversions.
23 return string(a) == string(b)
· · ·
27// The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
28// A nil argument is equivalent to an empty slice.
29▶func Compare(a, b []byte) int {
30 return bytealg.Compare(a, b)
31}
· · ·
33// explode splits s into a slice of UTF-8 sequences, one per Unicode code point (still slices of bytes),
34// up to a maximum of n byte slices. Invalid UTF-8 sequences are chopped into individual bytes.
35▶func explode(s []byte, n int) [][]byte {
36 if n <= 0 || n > len(s) {
37 n = len(s)
· · ·
56// Count counts the number of non-overlapping instances of sep in s.
57// If sep is an empty slice, Count returns 1 + the number of UTF-8-encoded code points in s.
58▶func Count(s, sep []byte) int {
59 // special case
60 if len(sep) == 0 {
+ 91 more matches in this file