Embed the shipped data, load any fs.FS, New takes options, Fake is safe for concurrent use

This commit is contained in:
2026-09-01 23:07:15 +02:00
parent 91cbae2a44
commit f210c7a764
5 changed files with 197 additions and 128 deletions
+2
View File
@@ -18,6 +18,8 @@ type rng interface {
// e.g. "sv_SE.address" or "sv_SE.address.street". Choices along the way are
// resolved at random. A path naming a folder (no value of its own) is an error.
func (f *Generator) Fake(path string) (string, error) {
f.mu.Lock()
defer f.mu.Unlock()
n, err := descend(f.rand, &group{children: f.categories}, strings.Split(path, "."))
if err != nil {
return "", fmt.Errorf("fejkdata: %s: %w", path, err)