parsePositiveNonZeroFloat parses a positive non-zero float64 option value
( ctx context.Context, o *options.Options, key string, args ...string, )
| 95 | |
| 96 | // parsePositiveNonZeroFloat parses a positive non-zero float64 option value |
| 97 | func (p *Parser) parsePositiveNonZeroFloat( |
| 98 | ctx context.Context, |
| 99 | o *options.Options, |
| 100 | key string, |
| 101 | args ...string, |
| 102 | ) error { |
| 103 | if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil { |
| 104 | return err |
| 105 | } |
| 106 | |
| 107 | f, err := strconv.ParseFloat(args[0], 64) |
| 108 | if err != nil || f <= 0 { |
| 109 | return newInvalidArgumentError(ctx, key, args[0], "positive number") |
| 110 | } |
| 111 | |
| 112 | o.Set(key, f) |
| 113 | |
| 114 | return nil |
| 115 | } |
| 116 | |
| 117 | // parseInt parses a positive integer option value |
| 118 | func (p *Parser) parseInt( |
no test coverage detected