1
0
mirror of https://github.com/google/uuid.git synced 2025-11-06 08:59:16 +02:00

166 Commits

Author SHA1 Message Date
Nicu Micle
2d3c2a9cc5 feat: Generate V6 from custom time (#172)
* Add NewV6WithTime

* Refactor generateV6

* fix NewV6WithTime doc comment

* fix: remove fmt.Println from test

---------

Co-authored-by: nicumicle <20170987+nicumicleI@users.noreply.github.com>
2024-11-14 11:04:50 -06:00
Jorge Massih
0e97ed3b53 feat: add error types for better validation (#166)
* feat: add error types

* fix: broken backward compatibility
2024-08-06 07:37:17 -07:00
Alex Bozhenko
d55c313874 docs: upd links to rfc9562 (#162)
* upd links to draft

* RFC 4122 -> 9562

* add extra comment

---------

Co-authored-by: bormanp <122468813+bormanp@users.noreply.github.com>
2024-07-01 11:23:50 -05:00
MikeWang
e8d82d30a3 feat: add Compare function (#163)
* feat: add Compare function

* fix comment
2024-07-01 11:15:43 -05:00
Youngjae Lee
53dda83ebe fix: incorrect timestamp in uuid v6 (#161) 2024-06-03 12:39:21 -05:00
kotaro.yamazaki
6e10cd1027 fix: use MustParse("xxx") instead of Must(Parse("xxxx")) (#106)
* fix to use MustParse

* use MustParse(...)  inseted of Must(Parse(...))

---------

Co-authored-by: Noah Dietz <noahdietz@users.noreply.github.com>
Co-authored-by: bormanp <122468813+bormanp@users.noreply.github.com>
2024-02-22 10:41:49 -06:00
Andreas Deininger
b5b9aeb1d1 docs: fixing typos (#156) 2024-02-12 10:07:22 -06:00
release-please[bot]
0f11ee6918 chore(master): release 1.6.0 (#151) v1.6.0 2024-01-23 11:54:04 -07:00
MikeWang
16939dafc3 chore(tests): add strict monotonicity test case for uuid v7. (#154)
* TestVersion7MonotonicityStrict

* reset timeNow and rand
2024-01-16 09:12:18 -06:00
David Kaufman
016b199544 fix: fix typo in version 7 uuid documentation (#153) 2024-01-12 13:22:15 -06:00
Joyce
1d8b6ea099 ci: set token permissions to github workflows (#143)
* The top level permission for github workflows were set to be content
read

Signed-off-by: Joyce Brum <joycebrum@google.com>
2024-01-11 12:41:20 -07:00
MikeWang
a2b2b32373 fix: Monotonicity in UUIDv7 (#150)
* Monotonicity in UUIDv7

* fix Monotonicity

* fix comment

* Monotonicity 2

* lock

* fix comment

* fix comment
2024-01-11 12:16:31 -06:00
MikeWang
c58770eb49 feat: add Max UUID constant (#149)
add Max uuid
2024-01-09 16:54:05 +00:00
release-please[bot]
4d47f8eb06 chore(master): release 1.5.0 (#145)
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
v1.5.0
2023-12-12 11:21:37 -06:00
Lucas JAHIER
9ee7366e66 feat: Validate UUID without creating new UUID (#141)
* feat: Validate UUID without creating new UUID

* fix: update comment
2023-12-11 18:19:23 -06:00
MikeWang
b35aa6a595 add uuid version 6 and 7 (#139)
* add uuid version 6 and 7

* fix comment
2023-11-23 17:50:18 -06:00
release-please[bot]
8de8764e29 chore(master): release 1.4.0 (#134)
🤖 I have created a release *beep* *boop*
---


## [1.4.0](https://togithub.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26)


### Features

* UUIDs slice type with Strings() convenience method ([#133](https://togithub.com/google/uuid/issues/133)) ([cd5fbbd](cd5fbbdd02))

### Fixes

* Clarify that Parse's job is to parse but not necessarily validate strings. (Documents current behavior)

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
v1.4.0
2023-10-26 15:24:04 +00:00
bormanp
7c22e97ff7 Clarify the documentation of Parse to state its job is to parse, not validate, strings. (#135) 2023-10-26 10:12:40 -05:00
Dylan Bargteil
cd5fbbdd02 feat: UUIDs slice type with Strings() convenience method (#133)
* feat: add uuid slice type with strings convenience method

* test: benchmark new UUIDs.Strings() feature

* docs: improve comments on UUIDs

* fix: typos in UUIDs strings benchmark
2023-10-26 09:07:35 -05:00
Oleksandr Redko
47f5b3936c docs: fix a typo in CONTRIBUTING.md (#130) 2023-09-21 07:50:21 -05:00
Noah Dietz
542ddabd47 chore(tests): add Fuzz tests (#128) 2023-08-22 08:58:23 -07:00
Vladimir Kochergin
06716f6a60 chore(tests): Add json.Unmarshal test with empty value cases (#116) 2023-08-21 11:32:02 -07:00
release-please[bot]
b3cae7c306 chore(master): release 1.3.1 (#127) v1.3.1 2023-08-21 09:29:15 -07:00
Noah Dietz
7b8f57cbcc fix(ci): switch to release-please app (#126) 2023-08-18 11:25:53 -07:00
Noah Dietz
e69e468f7c chore(ci): configure release-please, update contrib (#122) 2023-08-18 10:07:14 -07:00
Noah Dietz
97c970d2a5 chore(ci): add apidiff check for API compatibility (#123) 2023-08-18 10:05:16 -07:00
Oleksandr Redko
53f93a84e6 docs: change godoc URL in README (#124)
This PR replaces `godoc.org` with `pkg.go.dev` in README.
2023-08-18 16:00:04 +00:00
Curtis Lowder
0b416df5d0 docs: update link to RFC 4122 (#93)
Updates the README to fix the link to the RFC. Fixes #92.
2023-08-18 02:32:03 +00:00
NewCapital.in
75e1ac5ba6 docs: shell format go tool command (#111)
A little shorthand to make easier the `devExperience`.
2023-08-18 02:18:05 +00:00
Oleksandr Redko
d71986992e docs: fix typo node_js docs (#117)
This PR corrects a typo in the comment.
2023-08-17 23:04:03 +00:00
ayan george
574e687494 fix: Use .EqualFold() to parse urn prefixed UUIDs (#118)
Prior to this commit we used a comparison with the result of ToLower() to test for a "urn:uuid" prefix in both UUID strings and byte slices.

This commit replaces the ToLower and string comparison with both strings.EqualFold and bytes.EqualFold.

This reduces the CPU time across the board for UUIDs that start with "urn:uuid" and eliminates some allocations when parsing bytes.

The benchmark output was generated by adding "urn:uuid" to the test input.

```
goos: linux
goarch: amd64
pkg: github.com/google/uuid
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
                      │ /tmp/output1 │             /tmp/output2              │
                      │    sec/op    │    sec/op     vs base                 │
Parse-8                 35.87n ± ∞ ¹   33.75n ± ∞ ¹        ~ (p=1.000 n=1) ²
ParseBytes-8            65.10n ± ∞ ¹   35.56n ± ∞ ¹        ~ (p=1.000 n=1) ²
ParseBytesUnsafe-8      35.31n ± ∞ ¹   34.70n ± ∞ ¹        ~ (p=1.000 n=1) ²
ParseBytesCopy-8        78.01n ± ∞ ¹   61.21n ± ∞ ¹        ~ (p=1.000 n=1) ²
ParseBadLength-8        3.499n ± ∞ ¹   3.084n ± ∞ ¹        ~ (p=1.000 n=1) ²
ParseLen32Truncated-8   3.335n ± ∞ ¹   3.334n ± ∞ ¹        ~ (p=1.000 n=1) ²
ParseLen36Corrupted-8   63.02n ± ∞ ¹   58.26n ± ∞ ¹        ~ (p=1.000 n=1) ²
geomean                 24.11n         20.51n        -14.92%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                      │ /tmp/output1 │           /tmp/output2           │
                      │     B/op     │    B/op      vs base             │
Parse-8                  0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseBytes-8             16.00 ± ∞ ¹    0.00 ± ∞ ¹  ~ (p=1.000 n=1) ³
ParseBytesUnsafe-8       0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseBytesCopy-8         48.00 ± ∞ ¹   48.00 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseBadLength-8         0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseLen32Truncated-8    0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseLen36Corrupted-8    16.00 ± ∞ ¹   16.00 ± ∞ ¹  ~ (p=1.000 n=1) ²
geomean                            ⁴                ?               ⁴ ⁵
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal
³ need >= 4 samples to detect a difference at alpha level 0.05
⁴ summaries must be >0 to compute geomean
⁵ ratios must be >0 to compute geomean

                      │ /tmp/output1 │           /tmp/output2           │
                      │  allocs/op   │  allocs/op   vs base             │
Parse-8                  0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseBytes-8             1.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ³
ParseBytesUnsafe-8       0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseBytesCopy-8         1.000 ± ∞ ¹   1.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseBadLength-8         0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseLen32Truncated-8    0.000 ± ∞ ¹   0.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
ParseLen36Corrupted-8    1.000 ± ∞ ¹   1.000 ± ∞ ¹  ~ (p=1.000 n=1) ²
geomean                            ⁴                ?               ⁴ ⁵
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal
³ need >= 4 samples to detect a difference at alpha level 0.05
⁴ summaries must be >0 to compute geomean
⁵ ratios must be >0 to compute geomean
```
2023-08-17 21:18:03 +00:00
bormanp
c91929c8bf Merge pull request #121 from noahdietz/setup-codeowners-and-actions
chore(ci): add Action-based tests
2023-08-17 07:29:09 -05:00
Noah Dietz
e3f8b98b39 chore(ci): add Action-based tests (#121)
* chore(ci): add Action-based tests

* fix go1.20 resolving to go1.2
2023-08-16 19:00:26 -05:00
noahdietz
db89a3cfe2 fix go1.20 resolving to go1.2 2023-08-16 15:34:50 -07:00
noahdietz
78d68fcb27 chore(ci): add Action-based tests 2023-08-16 15:31:33 -07:00
Paul Borman
44b5fee7c4 Minor cleanup. v1.3.0 2021-07-12 17:33:52 -05:00
Paul Borman
e28eb7b914 Remove TestConformance from null_test.go. It was useful to demonstrate
the marshaling/unmarshaling was produced the output I expected.
2021-07-12 17:15:33 -05:00
Samuel Roth
ae25fc6a8e feat(uuid): Added support for NullUUID (#76) 2021-07-12 17:10:02 -05:00
Andrey Pechkurov
655bf50db9 Add randomness pool mode for V4 UUID (#80)
* Add randomness pool mode for V4 UUID

Adds an optional randomness pool mode for Random (Version 4)
UUID generation. The pool contains random bytes read from
the random number generator on demand in batches. Enabling
the pool may improve the UUID generation throughput
significantly.

Since the pool is stored on the Go heap, this feature may
be a bad fit for security sensitive applications. That's
why it's implemented as an opt-in feature.

* fixup! document thread-safety aspects
2021-07-08 10:05:48 -05:00
Charlie Lukman
512b657a42 feat: add public matcher function for custom error type invalidLengthError (#78) 2021-03-30 20:36:51 -05:00
jackterm
bfb86fa49a Add NewString Func (#73)
* added utility func

* updated docs & function call
v1.2.0
2021-01-22 12:20:15 -06:00
Yusuf Turhan Papurcu
b5d0d36c98 hash.go hash error covered and linter error fixed (#71)
* hash.go hash error covered and linter error fixed

Error covered without change function definition

* Update hash.go
v1.1.5
2021-01-14 18:27:13 -06:00
Steven Kaufman
93777840be Update sql.go (#72)
Added a single period so that the documentation doesn't look weird. Boy, I hope the tests pass.
2021-01-14 18:24:32 -06:00
Mitsuo Heijo
85223faccf Reduce custom error allocation (#70)
Zero allocation by using non-pointer error.

related #69

name               old time/op    new time/op    delta
ParseBadLength-16    15.4ns ± 0%     3.5ns ± 0%   ~     (p=1.000 n=1+1)

name               old alloc/op   new alloc/op   delta
ParseBadLength-16     8.00B ± 0%     0.00B        ~     (p=1.000 n=1+1)

name               old allocs/op  new allocs/op  delta
ParseBadLength-16      1.00 ± 0%      0.00        ~     (p=1.000 n=1+1)
v1.1.4
2021-01-04 13:17:18 -06:00
Joe Wreschnig
edef28d0c8 Use a custom error type for invalid lengths, replacing fmt.Errorf (#69)
* Add benchmarks for different kinds of invalid UUIDs

Also add a test case for too-short UUIDs to ensure behavior doesn’t
change.

* Use a custom error type for invalid lengths, replacing `fmt.Errorf`

This significantly improves the speed of failed parses due to wrong
lengths. Previously the `fmt.Errorf` call dominated, making this the
most expensive error and more expensive than successfully parsing:

    BenchmarkParse-4                 29226529        36.1 ns/op
    BenchmarkParseBadLength-4         6923106       174 ns/op
    BenchmarkParseLen32Truncated-4   26641954        38.1 ns/op
    BenchmarkParseLen36Corrupted-4   19405598        59.5 ns/op

When the formatting is not required and done on-demand, the failure per
se is much faster:

    BenchmarkParse-4                 29641700        36.3 ns/op
    BenchmarkParseBadLength-4        58602537        20.0 ns/op
    BenchmarkParseLen32Truncated-4   30664791        43.6 ns/op
    BenchmarkParseLen36Corrupted-4   18882410        61.9 ns/op
v1.1.3
2020-12-30 13:35:21 -06:00
Andrey Abramov
0e4e311974 Fix race in NewUUID() (#64)
* Fixed race in NewUUID()

* Remove unnecessary variable
v.1.1.2 v1.1.2
2020-07-02 13:56:42 -05:00
Tomáš Procházka
cb32006e48 refactor (*UUID).UnmarshalText (#58)
Now it's easier to set breakpoint on error for debugging.
2020-05-19 09:17:26 -05:00
Andy Pan
bd45158498 Resolved code issues of gofmt and golint (#55)
* Resolved code issues of gofmt and golint

Code quality: https://goreportcard.com/report/github.com/google/uuid

* Fix typo

* Update comment
2020-03-30 20:53:17 -05:00
pborman
7c63a14153 Merge pull request #53 from KosToZyB/master
Update README.md
2020-03-11 20:34:31 -05:00
Veselkov Konstantin
c78a2f96be Update README.md 2020-03-04 18:59:31 +04:00