rano/util/uid/uuid.go

24 lines
491 B
Go
Raw Normal View History

2024-11-18 15:23:13 +00:00
// 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()
}