feat: docs api design
This commit is contained in:
14
pkg/utils/ptr.go
Normal file
14
pkg/utils/ptr.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package utils
|
||||
|
||||
import "reflect"
|
||||
|
||||
func Ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
func Unptr[T any](v *T) T {
|
||||
if v == nil {
|
||||
return reflect.Zero(reflect.TypeOf(v).Elem()).Interface().(T)
|
||||
}
|
||||
return *v
|
||||
}
|
||||
Reference in New Issue
Block a user