bouncer/internal/store/id.go

20 lines
300 B
Go
Raw Normal View History

2023-04-24 20:52:12 +02:00
package store
import (
"github.com/google/uuid"
"github.com/pkg/errors"
)
func NewID() string {
return uuid.NewString()
}
func ParseID[T ~string](raw string) (T, error) {
uuid, err := uuid.Parse(raw)
if err != nil {
return *new(T), errors.WithStack(err)
}
return T(uuid.String()), nil
}