MCPcopy Index your code
hub / github.com/foxcpp/maddy / Float

Method Float

framework/config/map.go:557–571  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

555// See Custom function for details about inheritGlobal, required and
556// defaultVal.
557func (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.

Callers 2

TestMapFloatFunction · 0.95
TestMapFloat_InvalidFunction · 0.95

Calls 2

CustomMethod · 0.95
NodeErrFunction · 0.70

Tested by 2

TestMapFloatFunction · 0.76
TestMapFloat_InvalidFunction · 0.76