bytes介绍
官网:https://golang.org/pkg/bytes/#example_HasSuffix
对于传入 []byte 的函数,都不会修改传入的参数,返回值要么是参数的副本,要么是参数的切片。
-
func Compare(a, b []byte) int
// a < b 返回 -1;a == b 返回 0;a > b 返回 1 -
func Contains(b, subslice []byte) bool
-
func ContainsAny(b []byte, chars string) bool
-
func ContainsRune(b []byte, r rune) bool
-
func Equal(a, b []byte) bool
// 判断 a、b 是否相等 -
func EqualFold(s, t []byte) bool
// 判断 s、t 是否相似,忽略大写、小写、标题三种格式的区别。 -
func Fields(s []byte) [][]byte
// 以连续空白为分隔符将 s 切分成多个子串,结果不包含分隔符。 -
func FieldsFunc(s []byte, f func(rune) bool) [][]byte
// 以符合 f 的字符为分隔符将 s 切分成多个子串,结果不包含分隔符。 -
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
// 以 sep 为连接符,将子串列表 s 连接成一个字节串。
- 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
// 将子串 b 重复 count 次后返回。 - 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
// Split 以 sep 为分隔符将 s 切分成多个子串,结果不包含分隔符。
// 如果 sep 为空,则将 s 切分成 Unicode 字符列表。 - func SplitAfter(s, sep []byte) [][]byte
- func SplitAfterN(s, sep []byte, n int) [][]byte
- func SplitN(s, sep []byte, n int) [][]byte
// SplitN 可以指定切分次数 n,超出 n 的部分将不进行切分。 - func Title(s []byte) []byte
// 将 s 中的所有单词的首字符修改为 Title - func ToLower(s []byte) []byte
// s 中的所有字符修改为小写 - func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte
// 使用指定的映射表将 s 中的字符修改为小写 - func ToTitle(s []byte) []byte
// s 中的所有字符修改为标题 - func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte
// 使用指定的映射表将 s 中的字符修改为标题 - func ToUpper(s []byte) []byte
// s 中的所有字符修改为大写 - func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte
// 使用指定的映射表将 s 中的字符修改为大写 - func ToValidUTF8(s, replacement []byte) []byte
- func Trim(s []byte, cutset string) []byte
// 去掉 s 两边包含在 cutset 中的字符 - func TrimFunc(s []byte, f func(r rune) bool) []byte
- func TrimLeft(s []byte, cutset string) []byte
// 去掉 s 左边包含在 cutset 中的字符 - func TrimLeftFunc(s []byte, f func(r rune) bool) []byte
- func TrimPrefix(s, prefix []byte) []byte
// 去掉 s 的前缀 prefix(后缀 suffix)(返回 s 的切片)
- func TrimRight(s []byte, cutset string) []byte
// 去掉 s 右边包含在 cutset 中的字符 - func TrimRightFunc(s []byte, f func(r rune) bool) []byte
- func TrimSpace(s []byte) []byte
// 去掉 s 两边的空白(unicode.IsSpace)(返回 s 的切片) - func TrimSuffix(s, suffix []byte) []byte
- type Buffer
-
func NewBuffer(buf []byte) *Buffer
-
func NewBufferString(s string) *Buffer
-
func (b *Buffer) Bytes() []byte
-
func (b *Buffer) Cap() int
-
func (b *Buffer) Grow(n int)
-
func (b *Buffer) Len() int
-
func (b *Buffer) Next(n int) []byte
-
func (b *Buffer) Read(p []byte) (n int, err error)
-
func (b *Buffer) ReadByte() (byte, error)
-
func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)
-
func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)
-
func (b *Buffer) ReadRune() (r rune, size int, err error)
-
func (b *Buffer) ReadString(delim byte) (line string, err error)
-
func (b *Buffer) Reset()
-
func (b *Buffer) String() string
-
func (b *Buffer) Truncate(n int)
-
func (b *Buffer) UnreadByte() error
-
func (b *Buffer) UnreadRune() error
-
func (b *Buffer) Write(p []byte) (n int, err error)
-
func (b *Buffer) WriteByte(c byte) error
-
func (b *Buffer) WriteRune(r rune) (n int, err error)
-
func (b *Buffer) WriteString(s string) (n int, err error)
-
func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)
- type Reader
-
func NewReader(b []byte) *Reader
-
func (r *Reader) Len() int
-
func (r *Reader) Read(b []byte) (n int, err error)
-
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error)
-
func (r *Reader) ReadByte() (byte, error)
-
func (r *Reader) ReadRune() (ch rune, size int, err error)
-
func (r *Reader) Reset(b []byte)
-
func (r *Reader) Seek(offset int64, whence int) (int64, error)
-
func (r *Reader) Size() int64
-
func (r *Reader) UnreadByte() error
-
func (r *Reader) UnreadRune() error
-
func (r *Reader) WriteTo(w io.Writer) (n int64, err error)