Skip to content

Commit

Permalink
feat: add uuid in util
Browse files Browse the repository at this point in the history
  • Loading branch information
Q00 committed Dec 8, 2023
1 parent 6fc2a98 commit e053fbc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions util/uuid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package util

import (
"github.com/gofrs/uuid"
"time"
)

func CreateUUID() (*uuid.UUID, error) {
id, err := uuid.NewV6()
if err != nil {
return nil, err
}

return &id, nil
}

func UUIDTime(ID *uuid.UUID) (time.Time, error) {
ts, err := uuid.TimestampFromV6(*ID)
if err != nil {
return time.Time{}, err
}

t, err := ts.Time()
if err != nil {
return time.Time{}, err
}
return t, err
}

0 comments on commit e053fbc

Please sign in to comment.