Skip to content

Commit e0fadb5

Browse files
authored
Merge branch 'google:master' into master
2 parents 15fac01 + 0e97ed3 commit e0fadb5

File tree

15 files changed

+265
-47
lines changed

15 files changed

+265
-47
lines changed

.github/workflows/apidiff.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
branches:
66
- master
7+
permissions:
8+
contents: read
79
jobs:
810
compat:
911
runs-on: ubuntu-latest

.github/workflows/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
branches:
66
- master
7+
permissions:
8+
contents: read
79
jobs:
810
unit-tests:
911
strategy:

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## [1.6.0](https://github.com/google/uuid/compare/v1.5.0...v1.6.0) (2024-01-16)
4+
5+
6+
### Features
7+
8+
* add Max UUID constant ([#149](https://github.com/google/uuid/issues/149)) ([c58770e](https://github.com/google/uuid/commit/c58770eb495f55fe2ced6284f93c5158a62e53e3))
9+
10+
11+
### Bug Fixes
12+
13+
* fix typo in version 7 uuid documentation ([#153](https://github.com/google/uuid/issues/153)) ([016b199](https://github.com/google/uuid/commit/016b199544692f745ffc8867b914129ecb47ef06))
14+
* Monotonicity in UUIDv7 ([#150](https://github.com/google/uuid/issues/150)) ([a2b2b32](https://github.com/google/uuid/commit/a2b2b32373ff0b1a312b7fdf6d38a977099698a6))
15+
16+
## [1.5.0](https://github.com/google/uuid/compare/v1.4.0...v1.5.0) (2023-12-12)
17+
18+
19+
### Features
20+
21+
* Validate UUID without creating new UUID ([#141](https://github.com/google/uuid/issues/141)) ([9ee7366](https://github.com/google/uuid/commit/9ee7366e66c9ad96bab89139418a713dc584ae29))
22+
323
## [1.4.0](https://github.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26)
424

525

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# uuid
22
The uuid package generates and inspects UUIDs based on
3-
[RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122)
3+
[RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562)
44
and DCE 1.1: Authentication and Security Services.
55

66
This package is based on the github.com/pborman/uuid package (previously named
@@ -18,4 +18,4 @@ go get github.com/google/uuid
1818

1919
Full `go doc` style documentation for the package can be viewed online without
2020
installing this package by using the GoDoc site here:
21-
http://pkg.go.dev/github.com/google/uuid
21+
https://pkg.go.dev/github.com/google/uuid

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Package uuid generates and inspects UUIDs.
66
//
7-
// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security
7+
// UUIDs are based on RFC 9562(obsoletes RFC 4122) and DCE 1.1: Authentication and Security
88
// Services.
99
//
1010
// A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to

hash.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ import (
1212

1313
// Well known namespace IDs and UUIDs
1414
var (
15-
NameSpaceDNS = Must(Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
16-
NameSpaceURL = Must(Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8"))
17-
NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"))
18-
NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
15+
NameSpaceDNS = MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
16+
NameSpaceURL = MustParse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
17+
NameSpaceOID = MustParse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
18+
NameSpaceX500 = MustParse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
1919
Nil UUID // empty UUID, all zeros
20+
21+
// The Max UUID is special form of UUID that is specified to have all 128 bits set to 1.
22+
Max = UUID{
23+
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
24+
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
25+
}
2026
)
2127

2228
// NewHash returns a new UUID derived from the hash of space concatenated with
@@ -32,7 +38,7 @@ func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID {
3238
var uuid UUID
3339
copy(uuid[:], s)
3440
uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4)
35-
uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant
41+
uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 9562 variant
3642
return uuid
3743
}
3844

json_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
)
1212

13-
var testUUID = Must(Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479"))
13+
var testUUID = MustParse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
1414

1515
func TestJSON(t *testing.T) {
1616
type S struct {

null_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ func TestNullUUIDUnmarshalJSON(t *testing.T) {
205205
var nu NullUUID
206206
err := json.Unmarshal(jsonNull, &nu)
207207
if err != nil || nu.Valid {
208-
t.Errorf("expected nil when unmarshaling null, got %s", err)
208+
t.Errorf("expected nil when unmarshalling null, got %s", err)
209209
}
210210
err = json.Unmarshal(jsonUUID, &nu)
211211
if err != nil || !nu.Valid {
212-
t.Errorf("expected nil when unmarshaling null, got %s", err)
212+
t.Errorf("expected nil when unmarshalling null, got %s", err)
213213
}
214214
}

sql_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestScan(t *testing.T) {
1515
invalidTest := "f47ac10b-58cc-0372-8567-0e02b2c3d4"
1616

1717
byteTest := make([]byte, 16)
18-
byteTestUUID := Must(Parse(stringTest))
18+
byteTestUUID := MustParse(stringTest)
1919
copy(byteTest, byteTestUUID[:])
2020

2121
// sunny day tests
@@ -105,7 +105,7 @@ func TestScan(t *testing.T) {
105105

106106
func TestValue(t *testing.T) {
107107
stringTest := "f47ac10b-58cc-0372-8567-0e02b2c3d479"
108-
uuid := Must(Parse(stringTest))
108+
uuid := MustParse(stringTest)
109109
val, _ := uuid.Value()
110110
if val != stringTest {
111111
t.Error("Value() did not return expected string")

time.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ func (uuid UUID) Time() Time {
113113
var t Time
114114
switch uuid.Version() {
115115
case 6:
116-
time := binary.BigEndian.Uint64(uuid[:8]) // Ignore uuid[6] version b0110
116+
time := int64(binary.BigEndian.Uint32(uuid[0:4])) << 28
117+
time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 12
118+
time |= int64(binary.BigEndian.Uint16(uuid[6:8]) & 0xfff)
117119
t = Time(time)
118120
case 7:
119121
time := binary.BigEndian.Uint64(uuid[:8])

0 commit comments

Comments
 (0)