MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / parseDuration

Method parseDuration

pkg/filter/ql/parser.go:546–558  ·  view source on GitHub ↗

parseDuration parses a string and returns a duration literal.

()

Source from the content-addressed store, hash-verified

544
545// parseDuration parses a string and returns a duration literal.
546func (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.
561var ErrInvalidDuration = errors.New("invalid duration")

Callers 1

ParseSequenceMethod · 0.95

Calls 5

scanIgnoreWhitespaceMethod · 0.95
newParseErrorFunction · 0.85
tokstrFunction · 0.85
parseDurationFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected