Commit Graph

3 Commits

Author SHA1 Message Date
Joe Tsai
27af11f144 internal: improve use of detrand in descfmt and errors
Use a non-breaking space instead of two spaces to vary the output.
This keeps the mutated version aesthetically similar to the normal one.

Change-Id: Ib4ade2795004fe5b30e454e7e533e5a0e3a9ffa2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194157
Reviewed-by: Herbie Ong <herbie@google.com>
2019-09-09 18:30:00 +00:00
Joe Tsai
71acbc7b7d internal/detrand: support disabling detrand
Since detrand is an internal package, we can safely provide a function
that can be called to disable its functionality for testing purposes.

Change-Id: I26383e12a5832eb5af01952898a4c73f627d7aa5
Reviewed-on: https://go-review.googlesource.com/c/151678
Reviewed-by: Herbie Ong <herbie@google.com>
2018-11-29 07:49:45 +00:00
Joe Tsai
492a476312 internal/detrand: new package for deterministically random functionality
The use of math/rand in serialization is to provide some form of instability
to the output to provide a clear signal to the user that the should not
depend on the the property of stability. However, it is reasonable that users
expect the output for these to be deterministic.

As such, add a detrand package that provides deterministic, yet unstable
randomization functionality.

Since this package hashes the binary, it does impose a small initialization cost:
	Benchmark    100000    20712 ns/op    480 B/op    6 allocs/op

Change-Id: I232d0fea1789a4278079837a67ee2f63474a4364
Reviewed-on: https://go-review.googlesource.com/c/151340
Reviewed-by: Herbie Ong <herbie@google.com>
2018-11-27 02:14:04 +00:00