From c463bd16d80dffc02debbc0e7c15e6723a7c7318 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Wed, 4 Jun 2025 18:32:53 -0600 Subject: [PATCH] numeric uuids --- main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 584fb54..9e7d789 100644 --- a/main.go +++ b/main.go @@ -206,7 +206,7 @@ func CloneForColumn[T any](db *sql.DB, table, column string, from, to T, fixed m values := []any{} for _ = range uuidGenColumns { - values = append(values, fmt.Sprintf("'%s'", strings.ToUpper(uuid.New().String()))) + values = append(values, fmt.Sprintf("'%s'", guid())) } for _, arg := range args { values = append(values, *(arg.(*any))) @@ -243,7 +243,7 @@ func CloneForColumn[T any](db *sql.DB, table, column string, from, to T, fixed m func() string { uuids := make([]string, len(uuidGenColumns)) for i := range uuids { - uuids[i] = fmt.Sprintf("'%s'", strings.ToUpper(uuid.New().String())) + uuids[i] = fmt.Sprintf("'%s'", guid()) } s := strings.Join(uuids, ", ") if len(uuids) > 0 { @@ -399,6 +399,12 @@ func Select[T any](db *sql.DB, q string, args ...any) ([]T, error) { return results, rows.Err() } -guid() string { - +func guid() string { + s := []byte(uuid.New().String()) + for i := range s { + if 'A' <= s[i] && s[i] <= 'Z' { + s[i] = '0' + byte(int(s[i])%10) + } + } + return strings.ToUpper(string(s)) }