blob: afc5f7f9c6d20903e477a549ff4bdc961ea78c13 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package buffer
import (
"errors"
)
var ErrBadRead = errors.New("bad read")
type Buffer struct {
buf []byte
off int
}
func New(opts ...Option) *Buffer {
b := &Buffer{}
for _, opt := range opts {
opt(b)
}
return b
}
func (b *Buffer) Len() int {
return len(b.buf)
}
func (b *Buffer) Off() int {
return b.off
}
func (b *Buffer) Bytes() []byte {
return b.buf
}
|