gitlab.com/evatix-go/core@v1.3.55/typesconv/float.go (about) 1 package typesconv 2 3 import "gitlab.com/evatix-go/core/constants" 4 5 func FloatPtr(val float32) *float32 { 6 return &val 7 } 8 9 // FloatPtrToSimple if nil then 0 10 func FloatPtrToSimple(val *float32) float32 { 11 if val == nil { 12 return constants.Zero 13 } 14 15 return *val 16 } 17 18 // FloatPtrToSimpleDef if nil then 0 19 func FloatPtrToSimpleDef(val *float32, defVal float32) float32 { 20 if val == nil { 21 return defVal 22 } 23 24 return *val 25 } 26 27 // FloatPtrToDefPtr if nil then 0 28 func FloatPtrToDefPtr(val *float32, defVal float32) *float32 { 29 if val == nil { 30 return &defVal 31 } 32 33 return val 34 } 35 36 // FloatPtrDefValFunc if nil then executes returns defValFunc result as pointer 37 func FloatPtrDefValFunc(val *float32, defValFunc func() float32) *float32 { 38 if val == nil { 39 result := defValFunc() 40 41 return &result 42 } 43 44 return val 45 }