Read reads up to len(b) bytes from ra's reader into b. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, [io.EOF]. If end-of-file is reached, the reader will be closed.
(b []byte)
| 1068 | // of bytes read and any error encountered. At end of file, Read returns 0, |
| 1069 | // [io.EOF]. If end-of-file is reached, the reader will be closed. |
| 1070 | func (ra ReadAutoCloser) Read(b []byte) (n int, err error) { |
| 1071 | if ra.r == nil { |
| 1072 | return 0, io.EOF |
| 1073 | } |
| 1074 | n, err = ra.r.Read(b) |
| 1075 | if err == io.EOF { |
| 1076 | ra.Close() |
| 1077 | } |
| 1078 | return n, err |
| 1079 | } |
| 1080 | |
| 1081 | func newScanner(r io.Reader) *bufio.Scanner { |
| 1082 | scanner := bufio.NewScanner(r) |