Documentation
¶
Overview ¶
Package bytesx extends the bytes package.
Index ¶
- type Buffer
- func (b *Buffer) AppendBool(v bool)
- func (b *Buffer) AppendFloat(f float64, fmt byte, prec, bitSize int)
- func (b *Buffer) AppendInt(i int64)
- func (b *Buffer) AppendTime(t time.Time, layout string)
- func (b *Buffer) AppendUint(i uint64)
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) Len() int
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Write(bs []byte) (int, error)
- func (b *Buffer) WriteByte(v byte) error
- func (b *Buffer) WriteString(s string)
- type Pool
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer wraps a byte slice, providing convenience functions.
Example ¶
package main
import (
"fmt"
"github.com/hamba/pkg/bytesx"
)
func main() {
p := bytesx.NewPool(1024) // A Buffer is returned from a pool
buf := p.Get() // Buffer is Reset when getting it
buf.WriteString("Hello")
buf.Write([]byte(" World!"))
fmt.Println(buf.String())
p.Put(buf) // Release the buffer back to the pool
}
Output: Hello World!
func (*Buffer) AppendBool ¶
AppendBool appends a bool to the underlying buffer.
func (*Buffer) AppendFloat ¶
AppendFloat appends a float to the underlying buffer.
func (*Buffer) AppendTime ¶
AppendTime appends a time to the underlying buffer, in the given layout.
func (*Buffer) AppendUint ¶
AppendUint appends an unsigned integer to the underlying buffer.
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset resets the underlying byte slice. Subsequent writes re-use the slice's backing array.
func (*Buffer) WriteString ¶
WriteString writes a string to the Buffer.
Click to show internal directories.
Click to hide internal directories.