MCPcopy Create free account
hub / github.com/cortexlabs/cortex / Float32

Function Float32

pkg/lib/configreader/float32.go:44–56  ·  view source on GitHub ↗
(inter interface{}, v *Float32Validation)

Source from the content-addressed store, hash-verified

42}
43
44func Float32(inter interface{}, v *Float32Validation) (float32, error) {
45 if inter == nil {
46 if v.TreatNullAsZero {
47 return ValidateFloat32Provided(0, v)
48 }
49 return 0, ErrorCannotBeNull(v.Required)
50 }
51 casted, castOk := cast.InterfaceToFloat32(inter)
52 if !castOk {
53 return 0, ErrorInvalidPrimitiveType(inter, PrimTypeFloat)
54 }
55 return ValidateFloat32Provided(casted, v)
56}
57
58func Float32FromInterfaceMap(key string, iMap map[string]interface{}, v *Float32Validation) (float32, error) {
59 inter, ok := ReadInterfaceMapValue(key, iMap)

Callers 1

Float32FromInterfaceMapFunction · 0.70

Calls 4

InterfaceToFloat32Function · 0.92
ValidateFloat32ProvidedFunction · 0.85
ErrorCannotBeNullFunction · 0.85

Tested by

no test coverage detected