99> Generation module based on [ Google UUID] ( https://github.com/google/uuid ) .
1010
1111<!-- TOC -->
12-
1312* [ Installation] ( #installation )
1413* [ Documentation] ( #documentation )
15- * [UUID](#uuid)
16-
14+ * [ UUID V4 ] ( #uuid-v4 )
15+ * [ UUID V7 ] ( #uuid-v7 )
1716<!-- TOC -->
1817
1918## Installation
@@ -24,11 +23,11 @@ go get github.com/ankorstore/yokai/generate
2423
2524## Documentation
2625
27- ### UUID
26+ ### UUID V4
2827
29- This module provides an [ UuidGenerator] ( uuid/generator.go ) interface, allowing to generate UUIDs.
28+ This module provides an [ UuidGenerator] ( uuid/generator.go ) interface, allowing to generate UUIDs V4 .
3029
31- The ` DefaultUuidGenerator ` is based on [ Google UUID] ( https://github.com/google/uuid ) .
30+ The ` DefaultUuidGenerator ` implementing it is based on [ Google UUID] ( https://github.com/google/uuid ) .
3231
3332``` go
3433package main
@@ -70,4 +69,55 @@ func main() {
7069 generator := uuid.NewDefaultUuidGeneratorFactory ().Create ()
7170 fmt.Printf (" uuid: %s " , generator.Generate ()) // uuid: dcb5d8b3-4517-4957-a42c-604d11758561
7271}
72+ ```
73+
74+ ### UUID V7
75+
76+ This module provides an [ UuidV7Generator] ( uuidv7/generator.go ) interface, allowing to generate UUIDs V7.
77+
78+ The ` DefaultUuidV7Generator ` implementing it is based on [ Google UUID] ( https://github.com/google/uuid ) .
79+
80+ ``` go
81+ package main
82+
83+ import (
84+ " fmt"
85+
86+ " github.com/ankorstore/yokai/generate/uuidv7"
87+ uuidv7test " github.com/ankorstore/yokai/generate/generatetest/uuidv7"
88+ )
89+
90+ func main () {
91+ // default UUID V7 generator
92+ generator := uuidv7.NewDefaultUuidV7Generator ()
93+ uuid , _ := generator.Generate ()
94+ fmt.Printf (" uuid: %s " , uuid.String ()) // uuid: 018fdd68-1b41-7eb0-afad-57f45297c7c1
95+
96+ // test UUID generator (with deterministic value for testing, requires valid UUID v7)
97+ testGenerator , _ := uuidv7test.NewTestUuidV7Generator (" 018fdd7d-1576-7a21-900e-1399637bd1a1" )
98+ uuid, _ = testGenerator.Generate ()
99+ fmt.Printf (" uuid: %s " , uuid.String ()) // uuid: 018fdd7d-1576-7a21-900e-1399637bd1a1
100+ }
101+ ```
102+
103+ The module also provides a [ UuidV7GeneratorFactory] ( uuidv7/factory.go ) interface, to create
104+ the [ UuidV7Generator] ( uuidv7/generator.go ) instances.
105+
106+ The ` DefaultUuidV7GeneratorFactory ` generates ` DefaultUuidV7Generator ` instances.
107+
108+ ``` go
109+ package main
110+
111+ import (
112+ " fmt"
113+
114+ " github.com/ankorstore/yokai/generate/uuidv7"
115+ )
116+
117+ func main () {
118+ // default UUID generator factory
119+ generator := uuidv7.NewDefaultUuidV7GeneratorFactory ().Create ()
120+ uuid , _ := generator.Generate ()
121+ fmt.Printf (" uuid: %s " , uuid.String ()) // uuid: 018fdd68-1b41-7eb0-afad-57f45297c7c1
122+ }
73123```
0 commit comments