Skip to content

Commit 850e1ea

Browse files
authored
Merge pull request #28 from jp-ryuji/use-ulid
replace uuid with ulid
2 parents 80f0783 + b152d1c commit 850e1ea

File tree

11 files changed

+24
-20
lines changed

11 files changed

+24
-20
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This document provides essential context for AI models interacting with this pro
1313
* **Frameworks & Runtimes:** Standard Go runtime. No major web frameworks are currently in use.
1414
* **Databases:** The infrastructure layer is not yet implemented, but the directory structure (`internal/infrastructure/database`) suggests that a database, Postgres, will be used.
1515
* **Key Libraries/Dependencies:**
16-
* `github.com/google/uuid`: For generating universally unique identifiers.
16+
* `github.com/oklog/ulid/v2`: For generating universally unique lexicographically sortable identifiers.
1717
* **Package Manager(s):** Go Modules (`go mod`).
1818

1919
## 3. Architectural Patterns

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ require (
1111
entgo.io/ent v0.14.5
1212
github.com/aarondl/null/v9 v9.0.1
1313
github.com/go-playground/validator/v10 v10.27.0
14-
github.com/google/uuid v1.6.0
1514
github.com/jackc/pgx/v5 v5.7.5
1615
github.com/lucsky/cuid v1.2.1
16+
github.com/oklog/ulid/v2 v2.1.0
1717
github.com/ory/dockertest/v3 v3.12.0
1818
github.com/stretchr/testify v1.10.0
1919
go.uber.org/mock v0.6.0
@@ -44,6 +44,7 @@ require (
4444
github.com/gogo/protobuf v1.3.2 // indirect
4545
github.com/google/go-cmp v0.7.0 // indirect
4646
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
47+
github.com/google/uuid v1.3.0 // indirect
4748
github.com/hashicorp/hcl/v2 v2.18.1 // indirect
4849
github.com/jackc/pgpassfile v1.0.0 // indirect
4950
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect

go.sum

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
6565
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
6666
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
6767
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
68-
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
69-
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
68+
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
69+
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
7070
github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo=
7171
github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
7272
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
@@ -101,6 +101,8 @@ github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo=
101101
github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
102102
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
103103
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
104+
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
105+
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
104106
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
105107
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
106108
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
@@ -109,6 +111,7 @@ github.com/opencontainers/runc v1.2.3 h1:fxE7amCzfZflJO2lHXf4y/y8M1BoAqp+FVmG19o
109111
github.com/opencontainers/runc v1.2.3/go.mod h1:nSxcWUydXrsBZVYNSkTjoQ/N6rcyTtn+1SD5D4+kRIM=
110112
github.com/ory/dockertest/v3 v3.12.0 h1:3oV9d0sDzlSQfHtIaB5k6ghUCVMVLpAY8hwrqoCyRCw=
111113
github.com/ory/dockertest/v3 v3.12.0/go.mod h1:aKNDTva3cp8dwOWwb9cWuX84aH5akkxXRvO7KCwWVjE=
114+
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
112115
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
113116
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
114117
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

internal/domain/model/car.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package model
33
import (
44
"time"
55

6-
"github.com/google/uuid"
6+
"github.com/oklog/ulid/v2"
77
)
88

99
// Cars is a slice of Car
@@ -30,7 +30,7 @@ type CarRefs struct {
3030
// NewCar creates a new Car
3131
func NewCar(tenantID, model string, createdAt time.Time) *Car {
3232
return &Car{
33-
ID: uuid.New().String(),
33+
ID: ulid.Make().String(),
3434
TenantID: tenantID,
3535
Model: model,
3636
CreatedAt: createdAt,

internal/domain/model/company.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package model
33
import (
44
"time"
55

6-
"github.com/google/uuid"
6+
"github.com/oklog/ulid/v2"
77
)
88

99
// Companies is a slice of Company
@@ -29,7 +29,7 @@ type CompanyRefs struct{}
2929
// NewCompany creates a new Company
3030
func NewCompany(renterID, tenantID, name string, companySize CompanySize, createdAt time.Time) *Company {
3131
return &Company{
32-
ID: uuid.New().String(),
32+
ID: ulid.Make().String(),
3333
RenterID: renterID,
3434
TenantID: tenantID,
3535
Name: name,

internal/domain/model/individual.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"time"
55

66
"github.com/aarondl/null/v9"
7-
"github.com/google/uuid"
7+
"github.com/oklog/ulid/v2"
88

99
"github.com/jp-ryuji/go-sample/internal/domain/model/value"
1010
)
@@ -33,7 +33,7 @@ type IndividualRefs struct{}
3333
// NewIndividual creates a new Individual
3434
func NewIndividual(renterID, tenantID string, email value.Email, firstName, lastName null.String, createdAt time.Time) *Individual {
3535
return &Individual{
36-
ID: uuid.New().String(),
36+
ID: ulid.Make().String(),
3737
RenterID: renterID,
3838
TenantID: tenantID,
3939
Email: email,

internal/domain/model/option.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package model
33
import (
44
"time"
55

6-
"github.com/google/uuid"
6+
"github.com/oklog/ulid/v2"
77
)
88

99
// Options is a slice of Option
@@ -30,7 +30,7 @@ type OptionRefs struct {
3030
func NewOption(tenantID, name string) *Option {
3131
now := time.Now()
3232
return &Option{
33-
ID: uuid.New().String(),
33+
ID: ulid.Make().String(),
3434
TenantID: tenantID,
3535
Name: name,
3636
CreatedAt: now,

internal/domain/model/rental.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package model
33
import (
44
"time"
55

6-
"github.com/google/uuid"
6+
"github.com/oklog/ulid/v2"
77
)
88

99
// Rentals is a slice of Rental
@@ -36,7 +36,7 @@ type RentalRefs struct {
3636
func NewRental(tenantID, carID, renterID string, startsAt, endsAt time.Time) *Rental {
3737
now := time.Now()
3838
return &Rental{
39-
ID: uuid.New().String(),
39+
ID: ulid.Make().String(),
4040
TenantID: tenantID,
4141
CarID: carID,
4242
RenterID: renterID,

internal/domain/model/rental_option.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package model
33
import (
44
"time"
55

6-
"github.com/google/uuid"
6+
"github.com/oklog/ulid/v2"
77
)
88

99
// RentalOptions is a slice of RentalOption
@@ -33,7 +33,7 @@ type RentalOptionRefs struct {
3333
func NewRentalOption(tenantID, rentalID, optionID string, count int) *RentalOption {
3434
now := time.Now()
3535
return &RentalOption{
36-
ID: uuid.New().String(),
36+
ID: ulid.Make().String(),
3737
TenantID: tenantID,
3838
RentalID: rentalID,
3939
OptionID: optionID,

internal/domain/model/renter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package model
33
import (
44
"time"
55

6-
"github.com/google/uuid"
6+
"github.com/oklog/ulid/v2"
77
)
88

99
// Renters is a slice of Renter
@@ -37,7 +37,7 @@ type RenterRefs struct {
3737
// NewRenter creates a new Renter
3838
func NewRenter(tenantID string, renterType RenterType, createdAt time.Time) *Renter {
3939
return &Renter{
40-
ID: uuid.New().String(),
40+
ID: ulid.Make().String(),
4141
TenantID: tenantID,
4242
Type: renterType,
4343
CreatedAt: createdAt,

0 commit comments

Comments
 (0)