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