gconv_ptr.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gconv
  7. // PtrAny creates and returns an interface{} pointer variable to this value.
  8. func PtrAny(any interface{}) *interface{} {
  9. return &any
  10. }
  11. // PtrString creates and returns a string pointer variable to this value.
  12. func PtrString(any interface{}) *string {
  13. v := String(any)
  14. return &v
  15. }
  16. // PtrBool creates and returns a bool pointer variable to this value.
  17. func PtrBool(any interface{}) *bool {
  18. v := Bool(any)
  19. return &v
  20. }
  21. // PtrInt creates and returns an int pointer variable to this value.
  22. func PtrInt(any interface{}) *int {
  23. v := Int(any)
  24. return &v
  25. }
  26. // PtrInt8 creates and returns an int8 pointer variable to this value.
  27. func PtrInt8(any interface{}) *int8 {
  28. v := Int8(any)
  29. return &v
  30. }
  31. // PtrInt16 creates and returns an int16 pointer variable to this value.
  32. func PtrInt16(any interface{}) *int16 {
  33. v := Int16(any)
  34. return &v
  35. }
  36. // PtrInt32 creates and returns an int32 pointer variable to this value.
  37. func PtrInt32(any interface{}) *int32 {
  38. v := Int32(any)
  39. return &v
  40. }
  41. // PtrInt64 creates and returns an int64 pointer variable to this value.
  42. func PtrInt64(any interface{}) *int64 {
  43. v := Int64(any)
  44. return &v
  45. }
  46. // PtrUint creates and returns an uint pointer variable to this value.
  47. func PtrUint(any interface{}) *uint {
  48. v := Uint(any)
  49. return &v
  50. }
  51. // PtrUint8 creates and returns an uint8 pointer variable to this value.
  52. func PtrUint8(any interface{}) *uint8 {
  53. v := Uint8(any)
  54. return &v
  55. }
  56. // PtrUint16 creates and returns an uint16 pointer variable to this value.
  57. func PtrUint16(any interface{}) *uint16 {
  58. v := Uint16(any)
  59. return &v
  60. }
  61. // PtrUint32 creates and returns an uint32 pointer variable to this value.
  62. func PtrUint32(any interface{}) *uint32 {
  63. v := Uint32(any)
  64. return &v
  65. }
  66. // PtrUint64 creates and returns an uint64 pointer variable to this value.
  67. func PtrUint64(any interface{}) *uint64 {
  68. v := Uint64(any)
  69. return &v
  70. }
  71. // PtrFloat32 creates and returns a float32 pointer variable to this value.
  72. func PtrFloat32(any interface{}) *float32 {
  73. v := Float32(any)
  74. return &v
  75. }
  76. // PtrFloat64 creates and returns a float64 pointer variable to this value.
  77. func PtrFloat64(any interface{}) *float64 {
  78. v := Float64(any)
  79. return &v
  80. }