parseDuration parses a string and returns a duration literal.
()
| 544 | |
| 545 | // parseDuration parses a string and returns a duration literal. |
| 546 | func (p *Parser) parseDuration() (time.Duration, error) { |
| 547 | tok, pos, lit := p.scanIgnoreWhitespace() |
| 548 | if tok != Duration { |
| 549 | return 0, newParseError(tokstr(tok, lit), []string{"duration"}, pos, p.expr) |
| 550 | } |
| 551 | |
| 552 | d, err := parseDuration(lit) |
| 553 | if err != nil { |
| 554 | return 0, &ParseError{Message: err.Error(), Pos: pos} |
| 555 | } |
| 556 | |
| 557 | return d, nil |
| 558 | } |
| 559 | |
| 560 | // ErrInvalidDuration is returned when parsing a malformed duration. |
| 561 | var ErrInvalidDuration = errors.New("invalid duration") |
no test coverage detected