1
0
mirror of https://github.com/google/uuid.git synced 2024-11-28 08:49:08 +02:00
Commit Graph

142 Commits

Author SHA1 Message Date
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. 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
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
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)
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
2020-12-30 13:35:21 -06:00
Andrey Abramov
0e4e311974
Fix race in NewUUID() (#64)
* Fixed race in NewUUID()

* Remove unnecessary variable
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
pborman
c2e93f3ae5
Merge pull request #44 from trabetti/master
Allow concurrent, re-creatable usage
2019-04-16 12:24:45 -05:00
talis
f00b2048a8 remove uuid_source 2019-03-13 22:16:45 +02:00
talis
e23e7efa9b use strings.NewReader() instead of math/rand.Rand 2019-02-28 16:21:34 +02:00
talis
dc0f88720f Merge branch 'master' of https://github.com/google/uuid 2019-02-28 15:02:10 +02:00
talis
63b66ddfe0 reused version4 NewRandom() and added better testing 2019-02-28 14:59:24 +02:00
Paul Borman
0cd6bf5da1 Add darkfeline's change to set ifname if no interface is found. 2019-02-27 15:05:49 -06:00
talis
caad4a1123 simplify test 2019-02-26 09:40:33 +02:00
talis
005951d400 added source to enable concurrent reproducible usage 2019-02-20 09:43:18 +02:00
pborman
9b3b1e0f5f
Merge pull request #38 from dmitris/go-mod
add go.mod file
2018-09-17 09:00:05 -05:00
Dmitry Savintsev
364ba63b46 add go.mod file 2018-09-17 15:06:12 +02:00
pborman
2768d47f00
Merge pull request #37 from google/borman
Add new parsing support
2018-09-17 07:36:52 -05:00
Paul Borman
16ca3eab7d Add parsing support for:
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Resolves issue #24
2018-09-09 18:38:29 -05:00
pborman
e704694aed
Merge pull request #35 from OrlovEvgeny/master
edit slice
2018-08-28 13:15:55 -05:00
pborman
7cf75050e9
Merge pull request #26 from martinlindhe/mustparse
add MustParse(), which returns an UUID or panics
2018-08-28 13:14:23 -05:00
Paul Borman
d460ce9f8d Remove leftover comment.
Fix reamde to no longer say this is experimental.
The API is not going to change.
2018-08-27 15:42:32 -05:00
oj
81e4ea7833 edit slice 2018-08-24 16:43:38 +03:00
pborman
dec09d789f
Merge pull request #28 from elliott5/gopherjs
remove "net" dependency when targeting JS via GopherJS
2017-11-29 11:10:14 -08:00
Elliott Stoneham
a4243a3813 remove net when targeting JS 2017-11-29 12:54:27 +00:00
pborman
4ebdd04351
Merge pull request #27 from martinlindhe/master
fix some typos and trivial 'go vet'
2017-11-22 08:26:18 -08:00
Martin Lindhe
9c6b41367e fix some typos 2017-11-22 06:47:31 +01:00
Martin Lindhe
bb91e0b0e2 remove false claim about NewRandom() panic, pointed out in https://github.com/google/uuid/issues/12\#issue-232965368 2017-11-22 06:30:19 +01:00
Martin Lindhe
3d673cf3cf add MustParse(), which returns an UUID or panics 2017-11-22 06:20:00 +01:00
Martin Lindhe
1f1ba6fb7a make 'go vet' happy 2017-11-22 06:14:10 +01:00
pborman
8c31c18f31
Merge pull request #23 from loderunner/master
add FromBytes constructor
2017-11-13 08:03:52 -08:00