feat(utils): add pkg utils
This commit is contained in:
13
pkg/ptr/ptr.go
Normal file
13
pkg/ptr/ptr.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package ptr
|
||||
|
||||
func Of[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
func Deref[T any](v *T) T {
|
||||
var zeroT T
|
||||
if v == nil {
|
||||
return zeroT
|
||||
}
|
||||
return *v
|
||||
}
|
||||
Reference in New Issue
Block a user