Closed jonfriesen closed 4 years ago
Equal used to be here, but was removed because you can just use the ==
operator. See #36.
Merging #82 into master will increase coverage by
0.03%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #82 +/- ##
==========================================
+ Coverage 99.05% 99.09% +0.03%
==========================================
Files 4 4
Lines 318 330 +12
==========================================
+ Hits 315 327 +12
Misses 2 2
Partials 1 1
Impacted Files | Coverage Δ | |
---|---|---|
uuid.go | 100% <100%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update abfe188...65cfd5a. Read the comment docs.
Also, comparing UUIDs should just be bytes.Compare
I think.
@jadr2ddude thanks for responding! You make good points, my attempt to follow the RFC clouded more obvious solutions like ==
and bytes.Compare
:stuck_out_tongue:
feel free to close this PR
Hello! I didn't see a section on contributions, I hope I'm not overstepping with this proposal.
This change adds two functions, a
Compare(UUID, UUID) int
, and UUID attachedUUID.Equal(UUID) bool
:Compare takes two UUID's and returns -1 if the first UUID is lexically before the second, 0 if they are equal, and 1 if the first UUID is lexically after the second.
Equal takes a single UUID and compares to the attached returning true if they are equal and false if not. Equal makes use of Compare.
This implementation follows RFC 4122 where equality and order checks should be done by converting the UUID to a unsigned 128-bit integer and compared.
Tests included
Cheers! Jon