aboutsummaryrefslogtreecommitdiff
path: root/lib/uuidv7/example_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-04-06 16:29:02 +0700
committerShulhan <ms@kilabit.info>2026-04-06 16:29:02 +0700
commit0fd9dc3b4b9fe7acc0ebc498c2ab05a2e95a1239 (patch)
tree7072a3ef2035531e1ee1cb888fb602ed32251e45 /lib/uuidv7/example_test.go
parent6049c2e86450464d6bfdbbdb4fa2b4d64912ca01 (diff)
downloadpakakeh.go-0fd9dc3b4b9fe7acc0ebc498c2ab05a2e95a1239.tar.xz
lib/uuidv7: add suffix Func to Now and Rand
Using Func suffix to function variable is common coding styles in Go.
Diffstat (limited to 'lib/uuidv7/example_test.go')
-rw-r--r--lib/uuidv7/example_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/uuidv7/example_test.go b/lib/uuidv7/example_test.go
index 86ae7aab..2e23e6d1 100644
--- a/lib/uuidv7/example_test.go
+++ b/lib/uuidv7/example_test.go
@@ -15,13 +15,13 @@ import (
)
func ExampleGenerate() {
- // Begin mocking Now and Rand, DO NOT USE in production code.
+ // Begin mocking NowFunc and RandFunc, DO NOT USE in production code.
now := time.Date(2026, 3, 9, 14, 20, 0, 123456700, time.UTC)
- uuidv7.Now = func() time.Time {
+ uuidv7.NowFunc = func() time.Time {
now = now.Add(time.Second)
return now
}
- uuidv7.Rand = func() uint64 {
+ uuidv7.RandFunc = func() uint64 {
return 0xFFFF_FFFF_FFFF_FFFF
}
@@ -80,11 +80,11 @@ func ExampleUUID_IsEqual() {
func ExampleUUID_MarshalBinary() {
now := time.Date(2026, 3, 9, 14, 20, 0, 123456700, time.UTC)
- uuidv7.Now = func() time.Time {
+ uuidv7.NowFunc = func() time.Time {
now = now.Add(time.Second)
return now
}
- uuidv7.Rand = func() uint64 {
+ uuidv7.RandFunc = func() uint64 {
return 0xFFFF_FFFF_FFFF_FFFF
}
@@ -112,11 +112,11 @@ func ExampleUUID_MarshalBinary() {
func ExampleUUID_MarshalText() {
now := time.Date(2026, 3, 9, 14, 20, 0, 123456700, time.UTC)
- uuidv7.Now = func() time.Time {
+ uuidv7.NowFunc = func() time.Time {
now = now.Add(time.Second)
return now
}
- uuidv7.Rand = func() uint64 {
+ uuidv7.RandFunc = func() uint64 {
return 0xFFFF_FFFF_FFFF_FFFF
}