Answer architecture round 4: New keeps every module the loaded manifests read, and the note on a failed load names them all from one function beside noDataNote, so no category carries its source's modules

This commit is contained in:
2026-10-11 11:49:18 +02:00
committed by Lillem4n
parent 6e2555aee6
commit 165b67e843
9 changed files with 48 additions and 22 deletions
+5 -3
View File
@@ -31,6 +31,8 @@ type Generator struct {
drawState *drawstate.State
root folder // the categories as the node a path walks from, owned here so a walk allocates none
structs map[reflect.Type]structResult
// defaultModules is every module the loaded sources' manifests read by default.
defaultModules []string
}
type config struct {
@@ -107,15 +109,15 @@ func New(opts ...Option) (*Generator, error) {
if c.err != nil {
return nil, c.err
}
root, err := loadSources(c.sources)
root, modules, err := loadSources(c.sources)
if err != nil {
return nil, fmt.Errorf("fejkdata: %w", loadError{err})
return nil, fmt.Errorf("fejkdata: %w", withDefaultModules(loadError{err}, modules))
}
seed, err := c.drawSeed()
if err != nil {
return nil, fmt.Errorf("fejkdata: %w", err)
}
return &Generator{drawState: drawstate.New(seed), root: root}, nil
return &Generator{drawState: drawstate.New(seed), root: root, defaultModules: modules}, nil
}
// List returns the sorted dotted paths Fake renders: each category and every field,