23 September 2017

Table of Contents

  • constructor
  • Constants
  • Variables
  • function
    • [[func Compare(a, b []byte) int][func Compare(a, b []byte) int]]
    • [[func Contains(b, subslice []byte) bool][func Contains(b, subslice []byte) bool]]
    • [[func ContainsAny(b []byte, chars string) bool][func ContainsAny(b []byte, chars string) bool]]
    • [[func ContainsRune(b []byte, r rune) bool][func ContainsRune(b []byte, r rune) bool]]
    • [[func Count(s, sep []byte) int][func Count(s, sep []byte) int]]
    • [[func Equal(a, b []byte) bool][func Equal(a, b []byte) bool]]
    • [[func EqualFold(s, t []byte) bool][func EqualFold(s, t []byte) bool]]
    • [[func Fields(s []byte) [][]byte][func Fields(s []byte) [][]byte]]
    • [[func FieldsFunc(s []byte, f func(rune) bool) [][]byte][func FieldsFunc(s []byte, f func(rune) bool) [][]byte]]
    • [[func HasPrefix(s, prefix []byte) bool][func HasPrefix(s, prefix []byte) bool]]
    • [[func HasSuffix(s, suffix []byte) bool][func HasSuffix(s, suffix []byte) bool]]
    • [[func Index(s, sep []byte) int][func Index(s, sep []byte) int]]
    • [[func IndexAny(s []byte, chars string) int][func IndexAny(s []byte, chars string) int]]
    • [[func IndexByte(s []byte, c byte) int][func IndexByte(s []byte, c byte) int]]
    • [[func IndexFunc(s []byte, f func(r rune) bool) int][func IndexFunc(s []byte, f func(r rune) bool) int]]
    • [[func IndexRune(s []byte, r rune) int][func IndexRune(s []byte, r rune) int]]
    • [[func Join(s [][]byte, sep []byte) []byte][func Join(s [][]byte, sep []byte) []byte]]
    • [[func LastIndex(s, sep []byte) int][func LastIndex(s, sep []byte) int]]
    • [[func LastIndexAny(s []byte, chars string) int][func LastIndexAny(s []byte, chars string) int]]
    • [[func LastIndexByte(s []byte, c byte) int][func LastIndexByte(s []byte, c byte) int]]
    • [[func LastIndexFunc(s []byte, f func(r rune) bool) int][func LastIndexFunc(s []byte, f func(r rune) bool) int]]
    • [[func Map(mapping func(r rune) rune, s []byte) []byte][func Map(mapping func(r rune) rune, s []byte) []byte]]
    • [[func Repeat(b []byte, count int) []byte][func Repeat(b []byte, count int) []byte]]
    • [[func Replace(s, old, new []byte, n int) []byte][func Replace(s, old, new []byte, n int) []byte]]
    • [[func Runes(s []byte) []rune][func Runes(s []byte) []rune]]
    • [[func Split(s, sep []byte) [][]byte][func Split(s, sep []byte) [][]byte]]
    • [[func SplitAfter(s, sep []byte) [][]byte][func SplitAfter(s, sep []byte) [][]byte]]
    • [[func SplitAfterN(s, sep []byte, n int) [][]byte][func SplitAfterN(s, sep []byte, n int) [][]byte]]
    • [[func SplitN(s, sep []byte, n int) [][]byte][func SplitN(s, sep []byte, n int) [][]byte]]
    • [[func Title(s []byte) []byte][func Title(s []byte) []byte]]
    • [[func ToLower(s []byte) []byte][func ToLower(s []byte) []byte]]
    • [[func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte][func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte]]
    • [[func ToTitle(s []byte) []byte][func ToTitle(s []byte) []byte]]
    • [[func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte][func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte]]
    • [[func ToUpper(s []byte) []byte][func ToUpper(s []byte) []byte]]
    • [[func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte][func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte]]
    • [[func Trim(s []byte, cutset string) []byte][func Trim(s []byte, cutset string) []byte]]
    • [[func TrimFunc(s []byte, f func(r rune) bool) []byte][func TrimFunc(s []byte, f func(r rune) bool) []byte]]
    • [[func TrimLeft(s []byte, cutset string) []byte][func TrimLeft(s []byte, cutset string) []byte]]
    • [[func TrimLeftFunc(s []byte, f func(r rune) bool) []byte][func TrimLeftFunc(s []byte, f func(r rune) bool) []byte]]
    • [[func TrimPrefix(s, prefix []byte) []byte][func TrimPrefix(s, prefix []byte) []byte]]
    • [[func TrimRight(s []byte, cutset string) []byte][func TrimRight(s []byte, cutset string) []byte]]
    • [[func TrimRightFunc(s []byte, f func(r rune) bool) []byte][func TrimRightFunc(s []byte, f func(r rune) bool) []byte]]
    • [[func TrimSpace(s []byte) []byte][func TrimSpace(s []byte) []byte]]
    • [[func TrimSuffix(s, suffix []byte) []byte][func TrimSuffix(s, suffix []byte) []byte]]
  • type Buffer
  • type Reader

constructor

string to bytes

[]byte("xxx")

Constants

const MinRead = 512

Variables

var ErrTooLarge = errors.New("bytes.Buffer: too large")

function

func Compare(a, b []byte) int

func Contains(b, subslice []byte) bool

func ContainsAny(b []byte, chars string) bool

func ContainsRune(b []byte, r rune) bool

func Count(s, sep []byte) int

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(s []byte, c byte) int

func IndexFunc(s []byte, f func(r rune) bool) int

func IndexRune(s []byte, r rune) int

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 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 Title(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 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

type Buffer

type Buffer struct {
      // contains filtered or unexported fields
}

func NewBuffer(buf []byte) *Buffer

func NewBufferString(s string) *Buffer

var b bytes.Buffer // A Buffer needs no initialization.
b.Write([]byte("Hello "))
fmt.Fprintf(&b, "world!")
b.WriteTo(os.Stdout)
// A Buffer can turn a string or a []byte into an io.Reader.
buf := bytes.NewBufferString("R29waGVycyBydWxlIQ==")
dec := base64.NewDecoder(base64.StdEncoding, buf)
io.Copy(os.Stdout, dec)

func (b *Buffer) Bytes() []byte

func (b *Buffer) Cap() int

func (b *Buffer) Len() int

func (b *Buffer) Grow(n int)

var buff bytes.Buffer
fmt.Printf("%v\n", buff.Len())  // 0
fmt.Printf("%v\n", buff.Cap())  // 0

buff.Grow(64)                   // Grow Buffer Cap
bb := buff.Bytes()
buff.Write([]byte("64 bytes or fewer"))
fmt.Printf("%s\n", bb[:buff.Len()])

func (b *Buffer) Next(n int) []byte

var buff bytes.Buffer
buff.Grow(64)

buff.Write([]byte("abcdef"))
fmt.Printf("%s\n", buff.Next(1)) // a
fmt.Printf("%s\n", buff.Next(2)) // bc
fmt.Printf("%s\n", buff.Bytes()) // def

func (b *Buffer) Read(p []byte) (n int, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

b := make([]byte, 3)
buff.Read(b)
fmt.Printf("%s\n", b) // abc

buff.Read(b)
fmt.Printf("%s\n", b) // def

func (b *Buffer) ReadByte() (byte, error)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

b, err := buff.ReadByte()
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%c\n", b)   // a

func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

line, err := buff.ReadBytes(byte('b'))
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%s\n", line) // ab



var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

line, err := buff.ReadBytes(byte('z'))
if err != nil {
     log.Fatal(err)             // EOF
}
fmt.Printf("%s\n", line)

func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)

r := strings.NewReader("abc")
var buff bytes.Buffer
buff.ReadFrom(r)
fmt.Printf("%s\n", buff.Bytes()) // abc

func (b *Buffer) ReadRune() (r rune, size int, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

r, n, err := buff.ReadRune()
fmt.Printf("%v\n", r)   // 97
fmt.Printf("%v\n", n)   // 1
fmt.Printf("%v\n", err) // nil

func (b *Buffer) ReadString(delim byte) (line string, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

line, err := buff.ReadString(byte('b'))
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%s\n", line) // ab


var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

line, err := buff.ReadString(byte('z'))
if err != nil {
     log.Fatal(err) // EOF
}
fmt.Printf("%s\n", line)

func (b *Buffer) Reset()

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

line, err := buff.ReadString(byte('b'))
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%s\n", line) // ab

buff.Reset()
fmt.Printf("%v\n", buff.Len())  // 0
fmt.Printf("%v\n", buff.Cap())  // 64

func (b *Buffer) String() string

var buff1 bytes.Buffer
s1 := buff1.String()
fmt.Printf("%s\n", s1) // ""


var buff2 bytes.Buffer
buff2.Grow(64)
buff2.Write([]byte("abcdef"))
s2 := buff2.String()
fmt.Printf("%s\n", s2) // "abcdef"

func (b *Buffer) Truncate(n int)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

buff.Truncate(3)
fmt.Printf("%s\n", buff.Bytes()) // "abc"

buff.Truncate(0)
fmt.Printf("%s\n", buff.Bytes()) // ""

func (b *Buffer) UnreadByte() error

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

b, err := buff.ReadByte()
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%c\n", b)            // a
fmt.Printf("%s\n", buff.Bytes()) // bcdef

err = buff.UnreadByte()
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%s\n", buff.Bytes()) // abcdef

func (b *Buffer) UnreadRune() error

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))

b, _, err := buff.ReadRune()
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%c\n", b)            // a
fmt.Printf("%s\n", buff.Bytes()) // bcdef

err = buff.UnreadRune()
if err != nil {
     log.Fatal(err)
}
fmt.Printf("%s\n", buff.Bytes()) // abcdef

func (b *Buffer) Write(p []byte) (n int, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))
fmt.Printf("%s\n", buff.Bytes())

func (b *Buffer) WriteByte(c byte) error

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))
buff.WriteByte(byte('g'))
fmt.Printf("%s\n", buff.Bytes())

func (b *Buffer) WriteRune(r rune) (n int, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.Write([]byte("abcdef"))
buff.WriteByte(97)
fmt.Printf("%s\n", buff.Bytes())

func (b *Buffer) WriteString(s string) (n int, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.WriteString("abcdef")
fmt.Printf("%s\n", buff.Bytes())

func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)

var buff bytes.Buffer
buff.Grow(64)
buff.WriteString("abcdef")
buff.WriteTo(os.Stdout)
fmt.Printf("\n", buff.String())   // buff is empty

type Reader

func NewReader(b []byte) *Reader

r := bytes.NewReader([]byte("abc"))

b := make([]byte, 3)
r.Read(b)
fmt.Printf("%s\n", b)


r := bytes.NewReader([]byte("abc"))

b, _ := r.ReadByte()
fmt.Printf("%c\n", b)

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)