From 9fa75ca3cdee28d53be2c63194c62604fe4811a3 Mon Sep 17 00:00:00 2001 From: MK Date: Fri, 10 May 2024 10:54:37 -0400 Subject: [PATCH] finish updating rfc references to new number --- generator.go | 14 +++++++------- generator_test.go | 18 +++++++++--------- uuid.go | 20 ++++++++++---------- uuid_test.go | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/generator.go b/generator.go index 358aff9..20a6baa 100644 --- a/generator.go +++ b/generator.go @@ -230,7 +230,7 @@ func (g *Gen) NewV1() (UUID, error) { copy(u[10:], hardwareAddr) u.SetVersion(V1) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u, nil } @@ -239,7 +239,7 @@ func (g *Gen) NewV1() (UUID, error) { func (g *Gen) NewV3(ns UUID, name string) UUID { u := newFromHash(md5.New(), ns, name) u.SetVersion(V3) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u } @@ -251,7 +251,7 @@ func (g *Gen) NewV4() (UUID, error) { return Nil, err } u.SetVersion(V4) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u, nil } @@ -260,7 +260,7 @@ func (g *Gen) NewV4() (UUID, error) { func (g *Gen) NewV5(ns UUID, name string) UUID { u := newFromHash(sha1.New(), ns, name) u.SetVersion(V5) - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u } @@ -302,7 +302,7 @@ func (g *Gen) NewV6() (UUID, error) { u.SetVersion(V6) //overwrite first 2 bits of byte[8] for the variant - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u, nil } @@ -350,7 +350,7 @@ func (g *Gen) NewV7() (UUID, error) { return Nil, err } //override first 2 bits of byte[8] for the variant - u.SetVariant(VariantRFC4122) + u.SetVariant(VariantRFC9562) return u, nil } @@ -407,7 +407,7 @@ func (g *Gen) getHardwareAddr() ([]byte, error) { if _, err = io.ReadFull(g.rand, g.hardwareAddr[:]); err != nil { return } - // Set multicast bit as recommended by RFC-4122 + // Set multicast bit as recommended by RFC-9562 g.hardwareAddr[0] |= 0x01 }) if err != nil { diff --git a/generator_test.go b/generator_test.go index 934925a..70719e4 100644 --- a/generator_test.go +++ b/generator_test.go @@ -92,7 +92,7 @@ func testNewV1Basic(t *testing.T) { if got, want := u.Version(), V1; got != want { t.Errorf("generated UUID with version %d, want %d", got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("generated UUID with variant %d, want %d", got, want) } } @@ -110,7 +110,7 @@ func testNewV1BasicWithOptions(t *testing.T) { if got, want := u.Version(), V1; got != want { t.Errorf("generated UUID with version %d, want %d", got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("generated UUID with variant %d, want %d", got, want) } } @@ -249,7 +249,7 @@ func testNewV3Basic(t *testing.T) { if got, want := u.Version(), V3; got != want { t.Errorf("NewV3(%v, %q): got version %d, want %d", ns, name, got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("NewV3(%v, %q): got variant %d, want %d", ns, name, got, want) } want := "5df41881-3aed-3515-88a7-2f4a814cf09e" @@ -296,7 +296,7 @@ func testNewV4Basic(t *testing.T) { if got, want := u.Version(), V4; got != want { t.Errorf("got version %d, want %d", got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("got variant %d, want %d", got, want) } } @@ -383,7 +383,7 @@ func testNewV5Basic(t *testing.T) { if got, want := u.Version(), V5; got != want { t.Errorf("NewV5(%v, %q): got version %d, want %d", ns, name, got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("NewV5(%v, %q): got variant %d, want %d", ns, name, got, want) } want := "2ed6657d-e927-568b-95e1-2665a8aea6a2" @@ -433,7 +433,7 @@ func testNewV6Basic(t *testing.T) { if got, want := u.Version(), V6; got != want { t.Errorf("generated UUID with version %d, want %d", got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("generated UUID with variant %d, want %d", got, want) } } @@ -624,7 +624,7 @@ func makeTestNewV7Basic() func(t *testing.T) { if got, want := u.Version(), V7; got != want { t.Errorf("got version %d, want %d", got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("got variant %d, want %d", got, want) } } @@ -652,7 +652,7 @@ func makeTestNewV7TestVector() func(t *testing.T) { if got, want := u.Version(), V7; got != want { t.Errorf("got version %d, want %d", got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("got variant %d, want %d", got, want) } if got, want := u.String()[:15], "017f22e2-79b0-7"; got != want { @@ -677,7 +677,7 @@ func makeTestNewV7Basic10000000() func(t *testing.T) { if got, want := u.Version(), V7; got != want { t.Errorf("got version %d, want %d", got, want) } - if got, want := u.Variant(), VariantRFC4122; got != want { + if got, want := u.Variant(), VariantRFC9562; got != want { t.Errorf("got variant %d, want %d", got, want) } } diff --git a/uuid.go b/uuid.go index 89cf9eb..fb5405d 100644 --- a/uuid.go +++ b/uuid.go @@ -47,7 +47,7 @@ import ( // Size of a UUID in bytes. const Size = 16 -// UUID is an array type to represent the value of a UUID, as defined in RFC-4122. +// UUID is an array type to represent the value of a UUID, as defined in RFC-9562. type UUID [Size]byte // UUID versions. @@ -145,12 +145,12 @@ func TimestampFromV7(u UUID) (Timestamp, error) { return Timestamp(tsNanos), nil } -// Nil is the nil UUID, as specified in RFC-4122, that has all 128 bits set to +// Nil is the nil UUID, as specified in RFC-9562, that has all 128 bits set to // zero. var Nil = UUID{} -// Max is the maximum UUID, as specified in a draft of RFC-4122, that has all 128 bits -// set to one. This feature is subject to removal if it is removed from the final draft of the RFC. +// Max is the maximum UUID, as specified in RFC-9562, that has all 128 bits +// set to one. var Max = UUID{ 0xFF, 0xFF, @@ -194,7 +194,7 @@ func (u UUID) Variant() byte { case (u[8] >> 7) == 0x00: return VariantNCS case (u[8] >> 6) == 0x02: - return VariantRFC4122 + return VariantRFC9562 case (u[8] >> 5) == 0x06: return VariantMicrosoft case (u[8] >> 5) == 0x07: @@ -209,7 +209,7 @@ func (u UUID) Bytes() []byte { return u[:] } -// encodeCanonical encodes the canonical RFC-4122 form of UUID u into the +// encodeCanonical encodes the canonical RFC-9562 form of UUID u into the // first 36 bytes dst. func encodeCanonical(dst []byte, u UUID) { const hextable = "0123456789abcdef" @@ -230,7 +230,7 @@ func encodeCanonical(dst []byte, u UUID) { } } -// String returns a canonical RFC-4122 string representation of the UUID: +// String returns a canonical RFC-9562 string representation of the UUID: // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. func (u UUID) String() string { var buf [36]byte @@ -242,8 +242,8 @@ func (u UUID) String() string { // // The behavior is as follows: // The 'x' and 'X' verbs output only the hex digits of the UUID, using a-f for 'x' and A-F for 'X'. -// The 'v', '+v', 's' and 'q' verbs return the canonical RFC-4122 string representation. -// The 'S' verb returns the RFC-4122 format, but with capital hex digits. +// The 'v', '+v', 's' and 'q' verbs return the canonical RFC-9562 string representation. +// The 'S' verb returns the RFC-9562 format, but with capital hex digits. // The '#v' verb returns the "Go syntax" representation, which is a 16 byte array initializer. // All other verbs not handled directly by the fmt package (like '%p') are unsupported and will return // "%!verb(uuid.UUID=value)" as recommended by the fmt package. @@ -296,7 +296,7 @@ func (u *UUID) SetVariant(v byte) { switch v { case VariantNCS: u[8] = (u[8]&(0xff>>1) | (0x00 << 7)) - case VariantRFC4122: + case VariantRFC9562: u[8] = (u[8]&(0xff>>2) | (0x02 << 6)) case VariantMicrosoft: u[8] = (u[8]&(0xff>>3) | (0x06 << 5)) diff --git a/uuid_test.go b/uuid_test.go index 1b31be9..6dc97f9 100644 --- a/uuid_test.go +++ b/uuid_test.go @@ -83,7 +83,7 @@ func testUUIDVariant(t *testing.T) { }, { u: UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - want: VariantRFC4122, + want: VariantRFC9562, }, { u: UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},