MCPcopy
hub / github.com/nats-io/nats.go / Read

Method Read

ws_test.go:40–58  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

38}
39
40func (f *fakeReader) Read(p []byte) (int, error) {
41 f.mu.Lock()
42 closed := f.closed
43 f.mu.Unlock()
44 if closed {
45 return 0, io.EOF
46 }
47 for {
48 if f.buf.Len() > 0 {
49 n, err := f.buf.Read(p)
50 return n, err
51 }
52 buf, ok := <-f.ch
53 if !ok {
54 return 0, io.EOF
55 }
56 f.buf.Write(buf)
57 }
58}
59
60func (f *fakeReader) close() {
61 f.mu.Lock()

Calls 1

WriteMethod · 0.45

Tested by

no test coverage detected