Answer product-owner round 1: the seed docs say a new seed each run, not draws afresh, the README says to log a drawn seed to replay a run, and the changelog names WithSeed and the data options apart
This commit is contained in:
+5
-5
@@ -27,11 +27,11 @@ and any release may change what a seed draws, so pin one exact version
|
|||||||
error such as data that fails to load, and `2` on misuse.
|
error such as data that fails to load, and `2` on misuse.
|
||||||
- The library, `github.com/larvit/fejkdata`, for Go 1.22 or later on a 64-bit target.
|
- The library, `github.com/larvit/fejkdata`, for Go 1.22 or later on a 64-bit target.
|
||||||
`New` loads the modules `WithDataFS` names and the folders `WithDataPath` names, drawing
|
`New` loads the modules `WithDataFS` names and the folders `WithDataPath` names, drawing
|
||||||
from the seed `WithSeed` gives, and fails naming each of `WithSeed` and `WithDataFS`
|
from the seed `WithSeed` gives. It fails naming `WithSeed` where no seed is given, and
|
||||||
that is missing. The same seed repeats the draws while the version and data stay the
|
`WithDataFS` where neither option names the data. The same seed repeats the draws
|
||||||
same. `Fake` renders a path, and `FakeTemplate` and `NewTemplate` render a
|
while the version and data stay the same. `Fake` renders a path, and `FakeTemplate`
|
||||||
template. `FakeRecord`, `FakeRecordTemplate`
|
and `NewTemplate` render a template. `FakeRecord`, `FakeRecordTemplate` and
|
||||||
and `NewRecordTemplate` render a record, whose `JSON`, `CSVHeader`, `CSVLine` and
|
`NewRecordTemplate` render a record, whose `JSON`, `CSVHeader`, `CSVLine` and
|
||||||
`SQLInsert` methods write its columns as the CLI does. `FakeStruct` fills a struct's
|
`SQLInsert` methods write its columns as the CLI does. `FakeStruct` fills a struct's
|
||||||
`fake:"…"` tagged fields. `List` gives the paths `Fake` renders, direct descents only,
|
`fake:"…"` tagged fields. `List` gives the paths `Fake` renders, direct descents only,
|
||||||
and `IsTemplate` tells an inline template from a path. Data that fails to load gives
|
and `IsTemplate` tells an inline template from a path. Data that fails to load gives
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ ok, err := fejkdata.IsTemplate(arg) // an inline template by its shape, el
|
|||||||
|
|
||||||
| Option | |
|
| Option | |
|
||||||
|--------|--|
|
|--------|--|
|
||||||
| `WithSeed(n)` | required; same seed, version and data: identical sequence. `WithSeed(rand.Uint64())`, with `math/rand/v2`, draws afresh each run |
|
| `WithSeed(n)` | required; same seed, version and data: identical sequence. `WithSeed(s)` with `s := rand.Uint64()`, from `math/rand/v2`, takes a new seed each run; log `s` to replay a run |
|
||||||
| `WithDataPath(dir)` | layer a directory; repeat to layer several, the last wins a clash |
|
| `WithDataPath(dir)` | layer a directory; repeat to layer several, the last wins a clash |
|
||||||
| `WithDataFS(modules...)` | layer modules in order, each an `fs.FS`: a shipped package's `Modules()...`, or your own `embed.FS`; `WithDataFS()` loads none |
|
| `WithDataFS(modules...)` | layer modules in order, each an `fs.FS`: a shipped package's `Modules()...`, or your own `embed.FS`; `WithDataFS()` loads none |
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ type Option func(*config)
|
|||||||
|
|
||||||
// WithSeed seeds the generator, as [New] requires: two generators with the same seed,
|
// WithSeed seeds the generator, as [New] requires: two generators with the same seed,
|
||||||
// version and data emit identical sequences. WithSeed(rand.Uint64()), with math/rand/v2,
|
// version and data emit identical sequences. WithSeed(rand.Uint64()), with math/rand/v2,
|
||||||
// draws afresh each run.
|
// takes a new seed each run.
|
||||||
func WithSeed(seed uint64) Option {
|
func WithSeed(seed uint64) Option {
|
||||||
return func(c *config) { c.seed, c.seeded = seed, true }
|
return func(c *config) { c.seed, c.seeded = seed, true }
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ func WithDataFS(modules ...fs.FS) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNoSeed = errors.New(`fejkdata: no seed: add fejkdata.WithSeed(n) to repeat a run's output, or WithSeed(rand.Uint64()) (import "math/rand/v2") to draw afresh each run`)
|
var errNoSeed = errors.New(`fejkdata: no seed: add fejkdata.WithSeed(n) to repeat a run's output, or WithSeed(rand.Uint64()) (import "math/rand/v2") for a new seed each run`)
|
||||||
|
|
||||||
var errNoData = errors.New(`fejkdata: no data: add fejkdata.WithDataFS(data.Modules()...) (import "github.com/larvit/fejkdata/data") for all shipped data, WithDataFS/WithDataPath for your own, or WithDataFS() for none`)
|
var errNoData = errors.New(`fejkdata: no data: add fejkdata.WithDataFS(data.Modules()...) (import "github.com/larvit/fejkdata/data") for all shipped data, WithDataFS/WithDataPath for your own, or WithDataFS() for none`)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user