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