startOfLine represents the state where the next byte read from p.buf is the start of a line (or whitespace leading up to it).
()
| 142 | // startOfLine represents the state where the next byte read from p.buf is the |
| 143 | // start of a line (or whitespace leading up to it). |
| 144 | func (p *TextParser) startOfLine() stateFn { |
| 145 | p.lineCount++ |
| 146 | if p.skipBlankTab(); p.err != nil { |
| 147 | // This is the only place that we expect to see io.EOF, |
| 148 | // which is not an error but the signal that we are done. |
| 149 | // Any other error that happens to align with the start of |
| 150 | // a line is still an error. |
| 151 | if errors.Is(p.err, io.EOF) { |
| 152 | p.err = nil |
| 153 | } |
| 154 | return nil |
| 155 | } |
| 156 | switch p.currentByte { |
| 157 | case '#': |
| 158 | return p.startComment |
| 159 | case '\n': |
| 160 | return p.startOfLine // Empty line, start the next one. |
| 161 | } |
| 162 | return p.readingMetricName |
| 163 | } |
| 164 | |
| 165 | // startComment represents the state where the next byte read from p.buf is the |
| 166 | // start of a comment (or whitespace leading up to it). |