v0.4.0
What's Changed
- feat: allow reuse of random source by @gammazero in #37
For tests that need to keep generating random test data, it is more efficient to continue using the same random source instead of creating a new one each time data is generated. This also applies to the generation logic itself when one part of the generation logic uses another.
This PR lets the caller create a pseudo-random number source that can be uses reused for generating test data. This is also use within the test logic itself to avoid creating unnecessary random sources.
Also included in this PR are new functions, Name and NameSize, that generate fixed-size and random-size random name strings, and StringToSeed and Uint64ToSeed to create seed values.
This PR fixes two minor defects in the random/files package. First, random-size names never reached the maximum size. Second, the file names were more likely to contain a "0" due to its inclusion twice in the alphabet used for file name generation. Also fixes is a minor defect with ensuring unique addresses.
Finally, this PR migrates from /math/rand/ to /math/rand/v2 and uses ChaCha8 as its random number source.
Summary of changes in this PR:
- Enable reuse of pseudo-random source for data generation
- Internal efficiency improvements due to reuse of random source
- Fix error with ensuring unique addresses
- Fix minor defects with random file name generation
- Increases test coverage.
- Adds two new APIs
NameandNameSize, for generating fixes and random-sized random names. - No global seed or sequence.
- Added
StringToSeedandUint64ToSeedto create seed values - Update CLI tools to take strings to create seed values
- Move from
/math/randto /math/rand/v2`
The move to a different number generator, ChaCha8, means that different values will be generated than before, and tests depending on deterministic random values need to be updated.
⚠️ BREAKING API Changes
- Seed value changed from uint64 to [32]byte as needed for ChaCha8
- Do not support global seed
- Do not support global sequence
- Make
Sequencea separate type NewRandandNewSeededRandno longer create a*rand.Rand. This is only breaking in cases where*rand.Randis expected. Expectingio.Readerwill continue to work.BytesandBlocksOfSizenow take anint64as the size argument, which is more consistent with the golang standard library.- Deterministic random values output by API are different in this release.
Non-breaking API Changes
- Added Name and NameSize functions to API
- Added
NewSeedfunction to create new seed of type[32]byte - Added
StringToSeedandUint64ToSeedto create[32]byteseed values - Deprecated
NewRandandNewSeededRand
Full Changelog: v0.3.0...v0.4.0