15 lines
196 B
Go
Raw Permalink Normal View History

2023-03-22 22:45:17 +08:00
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
}