Skip to content

Commit b162e2a

Browse files
committed
fix: replace rfc4122 with rfc9562
1 parent 79f1bc6 commit b162e2a

File tree

7 files changed

+37
-25
lines changed

7 files changed

+37
-25
lines changed

.github/.dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ updates:
99
directory: "/"
1010
schedule:
1111
interval: "weekly"
12-
13-
- package-ecosystem: "github-actions"
12+
13+
- package-ecosystem: "github-actions"
1414
directory: ".github/workflows"
1515
schedule:
1616
interval: "weekly"

.github/workflows/go.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@ name: Go
55

66
on:
77
push:
8-
branches: [ "main" ]
8+
branches: ["main"]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: ["main"]
1111

1212
jobs:
13-
1413
build:
1514
runs-on: ubuntu-latest
1615
steps:
17-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v3
1817

19-
- name: Set up Go
20-
uses: actions/setup-go@v3
21-
with:
22-
go-version: 1.19
18+
- name: Set up Go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: 1.23
2322

24-
- name: Build
25-
run: go build -v ./...
23+
- name: Build
24+
run: go build -v ./...
2625

27-
- name: Test
28-
run: go test -v ./...
26+
- name: Test
27+
run: go test -v ./...

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ go get github.com/cmackenzie1/go-uuid
1313

1414
## Supported versions
1515

16-
| Version | Variant | Details |
17-
|-------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
18-
| `Version 4` | `10` | Pure random as defined in [RFC4122](https://www.rfc-editor.org/rfc/rfc4122). |
19-
| `Version 7` | `10` | Time-sortable as defined in a [working draft]( https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-uuid-version-7) meant to update [RFC4122](https://www.rfc-editor.org/rfc/rfc4122). |
16+
| Version | Variant | Details |
17+
| ----------- | ------- | ----------------------------------------------------------------------------------- |
18+
| `Version 4` | `10` | Pure random as defined in [RFC9562](https://www.rfc-editor.org/rfc/rfc9562.html). |
19+
| `Version 7` | `10` | Time-sortable as defined in [RFC9562](https://www.rfc-editor.org/rfc/rfc9562.html). |
2020

2121
## Usage
2222

@@ -53,7 +53,7 @@ func main() {
5353
- A single library with no external dependencies for multiple types of UUIDs.
5454
- `UUID` type is defined as a fixed-size, `[16]byte`, array which can be used as a map (instead of the 36 byte
5555
string representation). Over 2x space savings for memory!
56-
- Limited API. As per RFC4122, UUIDs (while containing embedded information), should be treated as opaque
56+
- Limited API. As per RFC9562, UUIDs (while containing embedded information), should be treated as opaque
5757
values. There is no temptation to build dependencies on the embedded information if you can't easily access it. 😉
5858

5959
### When should I use UUIDv7 over UUIDv4?
@@ -77,4 +77,4 @@ Please make sure to update tests as appropriate.
7777

7878
[MIT](./LICENSE.md)
7979

80-
[1]: https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#section-2.1
80+
[1]: https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#section-2.1

encoding_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ func TestNewV4_UnmarshalJSON(t *testing.T) {
7272
return exampleJSON{ID: uuid.Nil}
7373
},
7474
},
75+
"null": {
76+
uuid: "{\"id\":null}",
77+
want: func() exampleJSON {
78+
return exampleJSON{ID: uuid.Nil}
79+
},
80+
},
7581
}
7682

7783
for name, tt := range tests {

uuid.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ var (
1818
errUnsupportedVariant = errors.New("unsupported variant")
1919
)
2020

21-
// UUID is a 128 bit (16 byte) value defined by RFC4122.
21+
// UUID is a 128 bit (16 byte) value defined by RFC9562.
2222
type UUID [16]byte
2323

2424
// Nil represents the zero-value UUID
2525
var Nil UUID
2626

27-
// NewV4 returns a UUID Version 4 as defined in RFC4122. Random bits
27+
// NewV4 returns a UUID Version 4 as defined in RFC9562. Random bits
2828
// are generated using crypto/rand.
2929
//
3030
// 0 1 2 3
@@ -53,11 +53,11 @@ func NewV4() (UUID, error) {
5353
return uuid, nil
5454
}
5555

56-
// NewV7 returns a UUID Version 7 as defined in the drafted revision for RFC4122.
56+
// NewV7 returns a UUID Version 7 as defined in the drafted revision for RFC9562.
5757
// Random bits are generated using crypto/rand.
5858
// Due to millisecond resolution of the timestamp, UUIDs generated during the
5959
// same millisecond will sort arbitrarily.
60-
// https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-01.html#name-uuid-version-7
60+
// https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-version-7
6161
//
6262
// 0 1 2 3
6363
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

uuid_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,10 @@ func TestPrint(t *testing.T) {
109109
u, _ = NewV7()
110110
t.Logf("v7: %s %v", u, u[:])
111111
}
112+
113+
func BenchmarkNewV4(b *testing.B) {
114+
for i := 0; i < b.N; i++ {
115+
a, _ := NewV4()
116+
_ = a // prevent compiler optimization
117+
}
118+
}

0 commit comments

Comments
 (0)