24 lines
491 B
Go
24 lines
491 B
Go
// Copyright 2024 Patial Tech. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package uid
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gitserver.in/patialtech/rano/util/logger"
|
|
)
|
|
|
|
func NewUUID() string {
|
|
id, err := uuid.NewV7()
|
|
if err != nil {
|
|
logger.Incident(context.Background(), "New UUID", err.Error())
|
|
return fmt.Sprintf("%d", time.Now().UTC().UnixNano())
|
|
}
|
|
return id.String()
|
|
}
|