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