Debian Codegraph @

fs/fstestutil/record/buffer.go

raw symbols SCIP
1 package record
2
3 import (
4 "bytes"
5 "io"
6 "sync"
7 )
8
9 // Buffer is like bytes.Buffer but safe to access from multiple
10 // goroutines.
11 type Buffer struct {
12 mu sync.Mutex
13 buf bytes.Buffer
14 }
15
16 var _ = io.Writer(&Buffer{})
17
18 func (b *Buffer) Write(p []byte) (n int, err error) {
19 b.mu.Lock()
20 defer b.mu.Unlock()
21 return b.buf.Write(p)
22 }
23
24 func (b *Buffer) Bytes() []byte {
25 b.mu.Lock()
26 defer b.mu.Unlock()
27 return b.buf.Bytes()
28 }