Merge pull request 'util/id: add uuid helper func' (#385) from uuid into v3
Some checks failed
coverage / build (push) Successful in 9m9s
test / test (push) Failing after 12m2s

Reviewed-on: #385
This commit is contained in:
Василий Толстов 2024-12-23 11:00:04 +03:00
commit 5989fd54ca
2 changed files with 15 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"time"
uuidv8 "github.com/ash3in/uuidv8"
"github.com/google/uuid"
nanoid "github.com/matoous/go-nanoid"
)
@ -96,6 +97,10 @@ func New(opts ...Option) (string, error) {
return "", errors.New("invalid option, Type unspecified")
}
func ToUUID(s string) uuid.UUID {
return uuid.MustParse(s)
}
// Must is the same as New but fatals on error
func MustNew(opts ...Option) string {
id, err := New(opts...)

View File

@ -7,5 +7,14 @@ func TestUUIDv8(t *testing.T) {
if err != nil {
t.Fatal(err)
}
t.Logf("xxx %s\n", id)
_ = id
}
func TestToUUID(t *testing.T) {
id, err := New()
if err != nil {
t.Fatal(err)
}
u := ToUUID(id)
_ = u
}