Files
mats aa8b2bdedc
Build and Publish / BuildAndDeployAmd64 (push) Failing after 5s
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s
all the refactor
2026-06-28 17:51:52 +02:00

29 lines
648 B
Go

package order
import (
"fmt"
"git.k6n.net/mats/platform/uid"
)
// OrderId is a 64-bit order identifier with a compact base62 string form.
type OrderId uid.ID
// String returns the canonical base62 encoding.
func (id OrderId) String() string { return uid.ID(id).String() }
// NewOrderId generates a cryptographically random non-zero id.
func NewOrderId() (OrderId, error) {
id, err := uid.New()
if err != nil {
return 0, fmt.Errorf("NewOrderId: %w", err)
}
return OrderId(id), nil
}
// ParseOrderId parses a base62 string into an OrderId.
func ParseOrderId(s string) (OrderId, bool) {
id, ok := uid.Parse(s)
return OrderId(id), ok
}