feat: id utils

This commit is contained in:
Bobo
2025-06-04 15:52:46 +08:00
parent 3f713e489b
commit 99c8f6e4c1
22 changed files with 859 additions and 304 deletions

View File

@@ -1,6 +1,10 @@
package trans
import "time"
import (
"time"
"github.com/google/uuid"
)
func String(a string) *string {
return &a
@@ -527,3 +531,28 @@ func MapValues[TKey mapKeyValueType, TValue mapKeyValueType](source map[TKey]TVa
}
return target
}
func ToUuidPtr(str *string) *uuid.UUID {
var id *uuid.UUID
if str != nil {
_id, err := uuid.Parse(*str)
if err != nil {
return nil
}
id = &_id
}
return id
}
func ToUuid(str string) uuid.UUID {
id, _ := uuid.Parse(str)
return id
}
func ToStringPtr(id *uuid.UUID) *string {
var strUUID *string
if id != nil {
strUUID = Ptr(id.String())
}
return strUUID
}