Commit 96c4edf
* Add `uuid.Nil` and `.IsZero()` method
This simplifies comparisons with empty ULIDs. Right now, most people
are doing something like the following to check if a ULID is non-zero:
```go
id.Compare(ulid.ULID{}) == 0
```
This requires allocating a new empty ULID each time. Some packages
avoid this by creating their own global (or private) nil ULIDs on
initialization.
This should be built in and simple for better perf & a cleaner API.
* Update ulid.go
* Update ulid.go
* Update ulid.go
* Update ulid_test.go
* Update ulid_test.go
---------
Co-authored-by: Peter Bourgon <peterbourgon@users.noreply.github.com>
1 parent 8b543f4 commit 96c4edf
2 files changed
+22
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
419 | 427 | | |
420 | 428 | | |
421 | 429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
457 | 471 | | |
458 | 472 | | |
459 | 473 | | |
| |||
0 commit comments