startTimestamp represents the state where the next byte read from p.buf is the start of the timestamp (or whitespace leading up to it).
()
| 618 | // startTimestamp represents the state where the next byte read from p.buf is |
| 619 | // the start of the timestamp (or whitespace leading up to it). |
| 620 | func (p *TextParser) startTimestamp() stateFn { |
| 621 | if p.skipBlankTab(); p.err != nil { |
| 622 | return nil // Unexpected end of input. |
| 623 | } |
| 624 | if p.readTokenUntilWhitespace(); p.err != nil { |
| 625 | return nil // Unexpected end of input. |
| 626 | } |
| 627 | timestamp, err := strconv.ParseInt(p.currentToken.String(), 10, 64) |
| 628 | if err != nil { |
| 629 | // Create a more helpful error message. |
| 630 | p.parseError(fmt.Sprintf("expected integer as timestamp, got %q", p.currentToken.String())) |
| 631 | return nil |
| 632 | } |
| 633 | p.currentMetric.TimestampMs = proto.Int64(timestamp) |
| 634 | if p.readTokenUntilNewline(false); p.err != nil { |
| 635 | return nil // Unexpected end of input. |
| 636 | } |
| 637 | if p.currentToken.Len() > 0 { |
| 638 | p.parseError(fmt.Sprintf("spurious string after timestamp: %q", p.currentToken.String())) |
| 639 | return nil |
| 640 | } |
| 641 | return p.startOfLine |
| 642 | } |
| 643 | |
| 644 | // readingHelp represents the state where the last byte read (now in |
| 645 | // p.currentByte) is the first byte of the docstring after 'HELP'. |
nothing calls this directly
no test coverage detected