Documentation
¶
Index ¶
- func Clone(b []byte) []byte
- func Compare(a, b []byte) int
- func Contains(b, subslice []byte) bool
- func ContainsAny(b []byte, chars string) bool
- func ContainsByte(s []byte, b byte) bool
- func ContainsFunc(b []byte, f func(rune) bool) bool
- func ContainsRune(b []byte, r rune) bool
- func Count(s, sep []byte) int
- func CountByte(s []byte, b byte) int
- func Cut(s, sep []byte) (before, after []byte, found bool)
- func CutPrefix(s, prefix []byte) (after []byte, found bool)
- func CutSuffix(s, suffix []byte) (before []byte, found bool)
- func EndsWith(s []byte, b []byte) bool
- func EndsWithByte(s []byte, b byte) bool
- func Equal(a, b []byte) bool
- func EqualFold(s, t []byte) bool
- func Fields(s []byte) [][]byte
- func FieldsFunc(s []byte, f func(rune) bool) [][]byte
- func HasPrefix(s, prefix []byte) bool
- func HasSuffix(s, suffix []byte) bool
- func Index(s, sep []byte) int
- func IndexAny(s []byte, chars string) int
- func IndexByte(b []byte, c byte) int
- func IndexFunc(s []byte, f func(r rune) bool) int
- func IndexRune(s []byte, r rune) int
- func IsEmpty(s []byte) bool
- func Join(s [][]byte, sep []byte) []byte
- func LastIndex(s, sep []byte) int
- func LastIndexAny(s []byte, chars string) int
- func LastIndexByte(s []byte, c byte) int
- func LastIndexFunc(s []byte, f func(r rune) bool) int
- func Map(mapping func(r rune) rune, s []byte) []byte
- func Repeat(b []byte, count int) []byte
- func Replace(s, old, new []byte, n int) []byte
- func ReplaceAll(s, old, new []byte) []byte
- func Runes(s []byte) []rune
- func Split(s, sep []byte) [][]byte
- func SplitAfter(s, sep []byte) [][]byte
- func SplitAfterN(s, sep []byte, n int) [][]byte
- func SplitN(s, sep []byte, n int) [][]byte
- func StartsWith(s []byte, b []byte) bool
- func StartsWithByte(s []byte, b byte) bool
- func Strip(s []byte) []byte
- func StripLeft(s []byte) []byte
- func StripRight(s []byte) []byte
- func ToLower(s []byte) []byte
- func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte
- func ToTitle(s []byte) []byte
- func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte
- func ToUpper(s []byte) []byte
- func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte
- func ToValidUTF8(s, replacement []byte) []byte
- func Trim(s []byte, cutset string) []byte
- func TrimFunc(s []byte, f func(r rune) bool) []byte
- func TrimLeft(s []byte, cutset string) []byte
- func TrimLeftFunc(s []byte, f func(r rune) bool) []byte
- func TrimPrefix(s, prefix []byte) []byte
- func TrimRight(s []byte, cutset string) []byte
- func TrimRightFunc(s []byte, f func(r rune) bool) []byte
- func TrimSpace(s []byte) []byte
- func TrimSuffix(s, suffix []byte) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶ added in v1.2.8
Clone returns a copy of b[:len(b)]. The result may have additional unused capacity. Clone(nil) returns nil.
func 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 ContainsAny ¶
ContainsAny reports whether any of the UTF-8-encoded code points in chars are within b.
func ContainsByte ¶
ContainsByte reports whether the byte is contained in the slice s.
func ContainsFunc ¶ added in v1.2.8
ContainsFunc reports whether any of the UTF-8-encoded code points r within b satisfy f(r).
func ContainsRune ¶
ContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b.
func 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 Cut ¶ added in v1.2.8
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 CutPrefix ¶ added in v1.2.8
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 CutSuffix ¶ added in v1.2.8
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 EndsWithByte ¶
EndsWithByte Tests if the byte slice s ends with the specified suffix b.
func 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 EqualFold ¶
EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-insensitivity.
func 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 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). If f does not return consistent results for a given c, FieldsFunc may crash.
func Index ¶
Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func 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 IndexByte ¶
IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
func 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 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 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 LastIndex ¶
LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
func 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 LastIndexByte ¶
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
func 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 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 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 Replace ¶
Replace returns a copy of the slice s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the slice and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune slice. If n < 0, there is no limit on the number of replacements.
func ReplaceAll ¶
ReplaceAll returns a copy of the slice s with all non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the slice and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune slice.
func Runes ¶
Runes interprets s as a sequence of UTF-8-encoded code points. It returns a slice of runes (Unicode code points) equivalent to s.
func Split ¶
Split slices s into all subslices separated by sep and returns a slice of the subslices between those separators. If sep is empty, Split splits after each UTF-8 sequence. It is equivalent to SplitN with a count of -1.
func SplitAfter ¶
SplitAfter slices s into all subslices after each instance of sep and returns a slice of those subslices. If sep is empty, SplitAfter splits after each UTF-8 sequence. It is equivalent to SplitAfterN with a count of -1.
func SplitAfterN ¶
SplitAfterN slices s into subslices after each instance of sep and returns a slice of those subslices. If sep is empty, SplitAfterN splits after each UTF-8 sequence. The count determines the number of subslices to return:
n > 0: at most n subslices; the last subslice will be the unsplit remainder. n == 0: the result is nil (zero subslices) n < 0: all subslices
func SplitN ¶
SplitN slices s into subslices separated by sep and returns a slice of the subslices between those separators. If sep is empty, SplitN splits after each UTF-8 sequence. The count determines the number of subslices to return:
n > 0: at most n subslices; the last subslice will be the unsplit remainder. n == 0: the result is nil (zero subslices) n < 0: all subslices
func StartsWith ¶
StartsWith Tests if the byte slice s starts with the specified prefix b.
func StartsWithByte ¶
StartsWithByte Tests if the byte slice s starts with the specified prefix b.
func Strip ¶ added in v1.0.27
Strip returns a slice of the bytes s, with all leading and trailing white space removed, as defined by Unicode.
func StripLeft ¶ added in v1.0.27
StripLeft returns a slice of the bytes s, with all leading white space removed, as defined by Unicode.
func StripRight ¶ added in v1.0.27
StripRight returns a slice of the bytes s, with all trailing white space removed, as defined by Unicode.
func ToLower ¶
ToLower returns a copy of the byte slice s with all Unicode letters mapped to their lower case.
func ToLowerSpecial ¶
func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte
ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their lower case, giving priority to the special casing rules.
func ToTitle ¶
ToTitle treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their title case.
func ToTitleSpecial ¶
func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte
ToTitleSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their title case, giving priority to the special casing rules.
func ToUpper ¶
ToUpper returns a copy of the byte slice s with all Unicode letters mapped to their upper case.
func ToUpperSpecial ¶
func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte
ToUpperSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their upper case, giving priority to the special casing rules.
func ToValidUTF8 ¶
ToValidUTF8 treats s as UTF-8-encoded bytes and returns a copy with each run of bytes representing invalid UTF-8 replaced with the bytes in replacement, which may be empty.
func Trim ¶
Trim returns a subslice of s by slicing off all leading and trailing UTF-8-encoded code points contained in cutset.
func TrimFunc ¶
TrimFunc returns a subslice of s by slicing off all leading and trailing UTF-8-encoded code points c that satisfy f(c).
func TrimLeft ¶
TrimLeft returns a subslice of s by slicing off all leading UTF-8-encoded code points contained in cutset.
func TrimLeftFunc ¶
TrimLeftFunc treats s as UTF-8-encoded bytes and returns a subslice of s by slicing off all leading UTF-8-encoded code points c that satisfy f(c).
func TrimPrefix ¶
TrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
func TrimRight ¶
TrimRight returns a subslice of s by slicing off all trailing UTF-8-encoded code points that are contained in cutset.
func TrimRightFunc ¶
TrimRightFunc returns a subslice of s by slicing off all trailing UTF-8-encoded code points c that satisfy f(c).
func TrimSpace ¶
TrimSpace returns a subslice of s by slicing off all leading and trailing white space, as defined by Unicode.
func TrimSuffix ¶
TrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.
Types ¶
This section is empty.