Skip to content

Commit cd2dded

Browse files
Merge pull request #246 from gofrs/dbourque/modernize
Update the minimum supported Go version and modernize
2 parents ae2ac8e + 3336fd4 commit cd2dded

File tree

8 files changed

+47
-48
lines changed

8 files changed

+47
-48
lines changed

.github/workflows/go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Build
2121
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
2222
with:
23-
go-version: '1.22.x'
23+
go-version: '1.26.x'
2424

2525
- name: Check out code into the Go module directory
2626
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -45,7 +45,7 @@ jobs:
4545
- name: Build
4646
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
4747
with:
48-
go-version: '1.21.x'
48+
go-version: '1.25.x'
4949

5050
- name: Check out code into the Go module directory
5151
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ and parsing of UUIDs in different formats.
1515

1616
This package supports the following UUID versions:
1717

18-
* Version 1, based on timestamp and MAC address
19-
* Version 3, based on MD5 hashing of a named value
20-
* Version 4, based on random numbers
21-
* Version 5, based on SHA-1 hashing of a named value
22-
* Version 6, a k-sortable id based on timestamp, and field-compatible with v1
23-
* Version 7, a k-sortable id based on timestamp
18+
- Version 1, based on timestamp and MAC address
19+
- Version 3, based on MD5 hashing of a named value
20+
- Version 4, based on random numbers
21+
- Version 5, based on SHA-1 hashing of a named value
22+
- Version 6, a k-sortable id based on timestamp, and field-compatible with v1
23+
- Version 7, a k-sortable id based on timestamp
2424

2525
## Project History
2626

@@ -48,7 +48,7 @@ deficiencies.
4848

4949
## Requirements
5050

51-
This package requires Go 1.19 or later
51+
This package requires Go 1.25 or later
5252

5353
## Usage
5454

@@ -88,5 +88,5 @@ func main() {
8888

8989
## References
9090

91-
* [RFC-9562](https://tools.ietf.org/html/rfc9562) (replaces RFC-4122)
92-
* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01)
91+
- [RFC-9562](https://tools.ietf.org/html/rfc9562) (replaces RFC-4122)
92+
- [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01)

codec_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestFromBytes(t *testing.T) {
4646
})
4747
t.Run("Invalid", func(t *testing.T) {
4848
var short [][]byte
49-
for i := 0; i < len(codecTestData); i++ {
49+
for i := range codecTestData {
5050
short = append(short, codecTestData[:i])
5151
}
5252
var long [][]byte
@@ -298,7 +298,7 @@ func TestFromHexChar(t *testing.T) {
298298
for _, c := range []byte(hextable + strings.ToUpper(hextable)) {
299299
skip[c] = true
300300
}
301-
for i := 0; i < 256; i++ {
301+
for i := range 256 {
302302
c := byte(i)
303303
if !skip[c] {
304304
v := fromHexChar(c)
@@ -313,31 +313,31 @@ func TestFromHexChar(t *testing.T) {
313313
var stringBenchmarkSink string
314314

315315
func BenchmarkString(b *testing.B) {
316-
for i := 0; i < b.N; i++ {
316+
for range b.N {
317317
stringBenchmarkSink = codecTestUUID.String()
318318
}
319319
}
320320

321321
func BenchmarkFromBytes(b *testing.B) {
322-
for i := 0; i < b.N; i++ {
323-
FromBytes(codecTestData)
322+
for range b.N {
323+
_, _ = FromBytes(codecTestData)
324324
}
325325
}
326326

327327
func BenchmarkFromString(b *testing.B) {
328328
b.Run("canonical", func(b *testing.B) {
329-
for i := 0; i < b.N; i++ {
330-
FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
329+
for range b.N {
330+
_, _ = FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
331331
}
332332
})
333333
b.Run("urn", func(b *testing.B) {
334-
for i := 0; i < b.N; i++ {
335-
FromString("urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8")
334+
for range b.N {
335+
_, _ = FromString("urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8")
336336
}
337337
})
338338
b.Run("braced", func(b *testing.B) {
339-
for i := 0; i < b.N; i++ {
340-
FromString("{6ba7b810-9dad-11d1-80b4-00c04fd430c8}")
339+
for range b.N {
340+
_, _ = FromString("{6ba7b810-9dad-11d1-80b4-00c04fd430c8}")
341341
}
342342
})
343343
}
@@ -346,13 +346,13 @@ var FromBytesOrNilResult UUID
346346

347347
func BenchmarkFromBytesOrNil(b *testing.B) {
348348
b.Run("valid", func(b *testing.B) {
349-
for i := 0; i < b.N; i++ {
349+
for range b.N {
350350
FromBytesOrNilResult = FromBytesOrNil(codecTestData)
351351
}
352352
})
353353

354354
b.Run("empty", func(b *testing.B) {
355-
for i := 0; i < b.N; i++ {
355+
for range b.N {
356356
FromBytesOrNilResult = FromBytesOrNil([]byte{})
357357
}
358358
})
@@ -366,7 +366,7 @@ func BenchmarkUnmarshalText(b *testing.B) {
366366
b.Fatal(err)
367367
}
368368
b.ResetTimer()
369-
for i := 0; i < b.N; i++ {
369+
for range b.N {
370370
_ = u.UnmarshalText(text)
371371
}
372372
})
@@ -377,7 +377,7 @@ func BenchmarkUnmarshalText(b *testing.B) {
377377
b.Fatal(err)
378378
}
379379
b.ResetTimer()
380-
for i := 0; i < b.N; i++ {
380+
for range b.N {
381381
_ = u.UnmarshalText(text)
382382
}
383383
})
@@ -388,27 +388,27 @@ func BenchmarkUnmarshalText(b *testing.B) {
388388
b.Fatal(err)
389389
}
390390
b.ResetTimer()
391-
for i := 0; i < b.N; i++ {
391+
for range b.N {
392392
_ = u.UnmarshalText(text)
393393
}
394394
})
395395
}
396396

397397
func BenchmarkMarshalBinary(b *testing.B) {
398-
for i := 0; i < b.N; i++ {
399-
codecTestUUID.MarshalBinary()
398+
for range b.N {
399+
_, _ = codecTestUUID.MarshalBinary()
400400
}
401401
}
402402

403403
func BenchmarkMarshalText(b *testing.B) {
404-
for i := 0; i < b.N; i++ {
405-
codecTestUUID.MarshalText()
404+
for range b.N {
405+
_, _ = codecTestUUID.MarshalText()
406406
}
407407
}
408408

409409
func BenchmarkParseV4(b *testing.B) {
410410
const text = "f52a747a-983f-45f7-90b5-e84d70f470dd"
411-
for i := 0; i < b.N; i++ {
411+
for range b.N {
412412
var u UUID
413413
if err := u.Parse(text); err != nil {
414414
b.Fatal(err)

generator_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ func makeTestNewV7Basic10000000() func(t *testing.T) {
765765

766766
g := NewGen()
767767

768-
for i := 0; i < 10000000; i++ {
768+
for range 10000000 {
769769
u, err := g.NewV7()
770770
if err != nil {
771771
t.Fatal(err)
@@ -1103,32 +1103,32 @@ func TestDefaultHWAddrFunc(t *testing.T) {
11031103
func BenchmarkGenerator(b *testing.B) {
11041104
b.Run("NewV1", func(b *testing.B) {
11051105
for i := 0; i < b.N; i++ {
1106-
NewV1()
1106+
_, _ = NewV1()
11071107
}
11081108
})
11091109
b.Run("NewV3", func(b *testing.B) {
11101110
for i := 0; i < b.N; i++ {
1111-
NewV3(NamespaceDNS, "www.example.com")
1111+
_ = NewV3(NamespaceDNS, "www.example.com")
11121112
}
11131113
})
11141114
b.Run("NewV4", func(b *testing.B) {
11151115
for i := 0; i < b.N; i++ {
1116-
NewV4()
1116+
_, _ = NewV4()
11171117
}
11181118
})
11191119
b.Run("NewV5", func(b *testing.B) {
11201120
for i := 0; i < b.N; i++ {
1121-
NewV5(NamespaceDNS, "www.example.com")
1121+
_ = NewV5(NamespaceDNS, "www.example.com")
11221122
}
11231123
})
11241124
b.Run("NewV6", func(b *testing.B) {
11251125
for i := 0; i < b.N; i++ {
1126-
NewV6()
1126+
_, _ = NewV6()
11271127
}
11281128
})
11291129
b.Run("NewV7", func(b *testing.B) {
11301130
for i := 0; i < b.N; i++ {
1131-
NewV7()
1131+
_, _ = NewV7()
11321132
}
11331133
})
11341134
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/gofrs/uuid/v5
22

3-
go 1.19
3+
go 1.25

sql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (u UUID) Value() (driver.Value, error) {
3838
// Scan implements the sql.Scanner interface.
3939
// A 16-byte slice will be handled by UnmarshalBinary, while
4040
// a longer byte slice or a string will be handled by UnmarshalText.
41-
func (u *UUID) Scan(src interface{}) error {
41+
func (u *UUID) Scan(src any) error {
4242
switch src := src.(type) {
4343
case UUID: // support gorm convert from UUID to NullUUID
4444
*u = src
@@ -76,7 +76,7 @@ func (u NullUUID) Value() (driver.Value, error) {
7676
}
7777

7878
// Scan implements the sql.Scanner interface.
79-
func (u *NullUUID) Scan(src interface{}) error {
79+
func (u *NullUUID) Scan(src any) error {
8080
if src == nil {
8181
u.UUID, u.Valid = Nil, false
8282
return nil

sql_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func testSQLScanText(t *testing.T) {
8888
}
8989

9090
func testSQLScanUnsupported(t *testing.T) {
91-
unsupported := []interface{}{
91+
unsupported := []any{
9292
true,
9393
42,
9494
}
@@ -328,13 +328,13 @@ func BenchmarkNullMarshalJSON(b *testing.B) {
328328
}
329329
n := NullUUID{UUID: u, Valid: true}
330330
for i := 0; i < b.N; i++ {
331-
n.MarshalJSON()
331+
_, _ = n.MarshalJSON()
332332
}
333333
})
334334
b.Run("Invalid", func(b *testing.B) {
335335
n := NullUUID{Valid: false}
336336
for i := 0; i < b.N; i++ {
337-
n.MarshalJSON()
337+
_, _ = n.MarshalJSON()
338338
}
339339
})
340340
}
@@ -352,14 +352,14 @@ func BenchmarkNullUnmarshalJSON(b *testing.B) {
352352
b.Run("Valid", func(b *testing.B) {
353353
var u NullUUID
354354
for i := 0; i < b.N; i++ {
355-
u.UnmarshalJSON(data)
355+
_ = u.UnmarshalJSON(data)
356356
}
357357
})
358358
b.Run("Invalid", func(b *testing.B) {
359359
invalid := []byte("null")
360360
var n NullUUID
361361
for i := 0; i < b.N; i++ {
362-
n.UnmarshalJSON(invalid)
362+
_ = n.UnmarshalJSON(invalid)
363363
}
364364
})
365365
}

uuid_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ func BenchmarkFormat(b *testing.B) {
373373
}
374374
}
375375

376-
var uuidBenchmarkSink UUID
377376
var timestampBenchmarkSink Timestamp
378377
var timeBenchmarkSink time.Time
379378

0 commit comments

Comments
 (0)