Read populates the passed in byte slice with the value the ByteLoop was created with. Returns the size of bytes written. If the reader is closed, io.EOF will be returned.
(p []byte)
| 17 | // created with. Returns the size of bytes written. If the reader is closed, |
| 18 | // io.EOF will be returned. |
| 19 | func (l *ByteLoop) Read(p []byte) (size int, err error) { |
| 20 | l.mu.RLock() |
| 21 | defer l.mu.RUnlock() |
| 22 | if l.closed { |
| 23 | return 0, io.EOF |
| 24 | } |
| 25 | |
| 26 | for i := 0; i < len(p); i++ { |
| 27 | p[i] = l.value |
| 28 | } |
| 29 | return len(p), nil |
| 30 | } |
| 31 | |
| 32 | // Close closes the ByteLoop, and prevents any further reading. |
| 33 | func (l *ByteLoop) Close() error { |
nothing calls this directly
no outgoing calls
no test coverage detected