Float maps configuration directive with the specified name to variable referenced by 'store' pointer. Configuration directive must be in form 'name 123.55'. See Custom function for details about inheritGlobal, required and defaultVal.
(name string, inheritGlobal, required bool, defaultVal float64, store *float64)
| 555 | // See Custom function for details about inheritGlobal, required and |
| 556 | // defaultVal. |
| 557 | func (m *Map) Float(name string, inheritGlobal, required bool, defaultVal float64, store *float64) { |
| 558 | m.Custom(name, inheritGlobal, required, func() (interface{}, error) { |
| 559 | return defaultVal, nil |
| 560 | }, func(_ *Map, node Node) (interface{}, error) { |
| 561 | if len(node.Args) != 1 { |
| 562 | return nil, NodeErr(node, "expected 1 argument") |
| 563 | } |
| 564 | |
| 565 | f, err := strconv.ParseFloat(node.Args[0], 64) |
| 566 | if err != nil { |
| 567 | return nil, NodeErr(node, "invalid float: %s", node.Args[0]) |
| 568 | } |
| 569 | return f, nil |
| 570 | }, store) |
| 571 | } |
| 572 | |
| 573 | // Custom maps configuration directive with the specified name to variable |
| 574 | // referenced by 'store' pointer. |