MCPcopy Create free account
hub / github.com/amp-labs/connectors / GetFloat

Method GetFloat

common/stringMap.go:148–163  ·  view source on GitHub ↗

GetFloat extracts a float from the map.

(key string)

Source from the content-addressed store, hash-verified

146
147// GetFloat extracts a float from the map.
148func (m StringMap) GetFloat(key string) (float64, error) {
149 val, err := m.Get(key)
150 if err != nil {
151 return 0, err
152 }
153
154 t := reflect.TypeOf(val)
155
156 //nolint:exhaustive
157 switch t.Kind() {
158 case reflect.Float32, reflect.Float64:
159 return reflect.ValueOf(val).Float(), nil
160 default:
161 return 0, fmt.Errorf("%w: expected a float, but received %T", errFieldTypeMismatch, val)
162 }
163}
164
165func (m StringMap) GetNumber(key string) (float64, error) {
166 val, err := m.Get(key)

Callers 2

TestStringMapFunction · 0.95
RecordIdMethod · 0.80

Calls 1

GetMethod · 0.95

Tested by 1

TestStringMapFunction · 0.76