+ utils_type.go
This commit is contained in:
56
utils/utils_type.go
Normal file
56
utils/utils_type.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package utils
|
||||
|
||||
func String2Pointer(value string) *string {
|
||||
return &value
|
||||
}
|
||||
|
||||
func Pointer2String(ptr *string) (value string) {
|
||||
if ptr != nil {
|
||||
value = *ptr
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func Int2Pointer(value int) *int {
|
||||
return &value
|
||||
}
|
||||
|
||||
func Pointer2Int(ptr *int) (value int) {
|
||||
if ptr != nil {
|
||||
value = *ptr
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func Int64ToPointer(value int64) *int64 {
|
||||
return &value
|
||||
}
|
||||
|
||||
func Pointer2Int64(ptr *int64) (value int64) {
|
||||
if ptr != nil {
|
||||
value = *ptr
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func Float32ToPointer(value float32) *float32 {
|
||||
return &value
|
||||
}
|
||||
|
||||
func Pointer2Float32(ptr *float32) (value float32) {
|
||||
if ptr != nil {
|
||||
value = *ptr
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func Float64ToPointer(value float64) *float64 {
|
||||
return &value
|
||||
}
|
||||
|
||||
func Pointer2Float64(ptr *float64) (value float64) {
|
||||
if ptr != nil {
|
||||
value = *ptr
|
||||
}
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user