fix: rename util
All checks were successful
Check / check (push) Successful in 1m22s
Check / update (push) Has been skipped
Check / push (push) Successful in 13s

This commit is contained in:
2025-06-16 12:50:23 -04:00
parent 534a6e2bf9
commit 99379efa15
4 changed files with 13 additions and 13 deletions

View File

@ -0,0 +1,17 @@
package putil
func DerefOrEmpty[T any](val *T) T {
if val == nil {
var empty T
return empty
}
return *val
}
func IsNotNil[T any](val *T) bool {
return val != nil
}
func ToPointer[T any](val T) *T {
return &val
}

View File

@ -0,0 +1,44 @@
package putil
import (
"fmt"
"time"
"google.golang.org/protobuf/types/known/timestamppb"
)
func NullLike(s *string) *string {
if s == nil {
return nil
}
ts := fmt.Sprintf("%%%s%%", *s)
return &ts
}
func NullTimestamp(ts *timestamppb.Timestamp) *time.Time {
if ts == nil {
return nil
}
t := ts.AsTime()
return &t
}
func NullFloat64(f *float32) *float64 {
if f == nil {
return nil
}
f64 := float64(*f)
return &f64
}
func NullInt64(i *int32) *int64 {
if i == nil {
return nil
}
i64 := int64(*i)
return &i64
}