startTimestamp represents the state where the next byte read from p.buf is the start of the timestamp (or whitespace leading up to it).
()
| 472 | // startTimestamp represents the state where the next byte read from p.buf is |
| 473 | // the start of the timestamp (or whitespace leading up to it). |
| 474 | func (p *TextParser) startTimestamp() stateFn { |
| 475 | if p.skipBlankTab(); p.err != nil { |
| 476 | return nil // Unexpected end of input. |
| 477 | } |
| 478 | if p.readTokenUntilWhitespace(); p.err != nil { |
| 479 | return nil // Unexpected end of input. |
| 480 | } |
| 481 | timestamp, err := strconv.ParseInt(p.currentToken.String(), 10, 64) |
| 482 | if err != nil { |
| 483 | // Create a more helpful error message. |
| 484 | p.parseError(fmt.Sprintf("expected integer as timestamp, got %q", p.currentToken.String())) |
| 485 | return nil |
| 486 | } |
| 487 | p.currentMetric.TimestampMs = proto.Int64(timestamp) |
| 488 | if p.readTokenUntilNewline(false); p.err != nil { |
| 489 | return nil // Unexpected end of input. |
| 490 | } |
| 491 | if p.currentToken.Len() > 0 { |
| 492 | p.parseError(fmt.Sprintf("spurious string after timestamp: %q", p.currentToken.String())) |
| 493 | return nil |
| 494 | } |
| 495 | return p.startOfLine |
| 496 | } |
| 497 | |
| 498 | // readingHelp represents the state where the last byte read (now in |
| 499 | // p.currentByte) is the first byte of the docstring after 'HELP'. |
nothing calls this directly
no test coverage detected