github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/tools/ptr.go (about) 1 package tools 2 3 func BoolPtr(in bool) (out *bool) { 4 out = new(bool) 5 *out = in 6 7 return 8 } 9 10 func StringPtr(in string) (out *string) { 11 if in == "" { 12 return 13 } 14 out = new(string) 15 *out = in 16 17 return 18 } 19 20 func Int64Ptr(in int64) (out *int64) { 21 if in == 0 { 22 return 23 } 24 out = new(int64) 25 *out = in 26 27 return 28 } 29 30 func Int32Ptr(in int32) (out *int32) { 31 if in == 0 { 32 return 33 } 34 out = new(int32) 35 *out = in 36 37 return 38 } 39 40 func Uint64Ptr(in uint64) (out *uint64) { 41 if in == 0 { 42 return 43 } 44 out = new(uint64) 45 *out = in 46 47 return 48 } 49 50 func Uint32Ptr(in uint32) (out *uint32) { 51 if in == 0 { 52 return 53 } 54 out = new(uint32) 55 *out = in 56 57 return 58 } 59 60 func IntPtr(in int) (out *int) { 61 if in == 0 { 62 return 63 } 64 out = new(int) 65 *out = in 66 67 return 68 } 69 70 func UintPtr(in uint) (out *uint) { 71 if in == 0 { 72 return 73 } 74 out = new(uint) 75 *out = in 76 77 return 78 }