Answer architecture round 6: a manifest's reads names namespaces, loadReached notes only those nothing loaded provides, a mounted module labels its files by its namespace, Source.Load checks its mount, and the README keeps namespace and reads in an edited copy
This commit is contained in:
@@ -31,7 +31,7 @@ func (f *Generator) FakeStruct(v any) error {
|
||||
defer f.mu.Unlock()
|
||||
shape, err := f.structShapeOf(p.Elem().Type())
|
||||
if err != nil {
|
||||
return fmt.Errorf("fejkdata: %w", withDefaultModules(err, f.defaultModules))
|
||||
return fmt.Errorf("fejkdata: %w", err)
|
||||
}
|
||||
shape.fill(f.drawState, p.Elem())
|
||||
return nil
|
||||
@@ -55,7 +55,7 @@ func (f *Generator) structShapeOf(t reflect.Type) (*structShape, error) {
|
||||
if label == "" {
|
||||
label = "struct"
|
||||
}
|
||||
sc := &structCompile{root: &f.root, visiting: map[reflect.Type]bool{}, structsLeft: maxStructs}
|
||||
sc := &structCompile{root: &f.root, reads: f.manifestReads, visiting: map[reflect.Type]bool{}, structsLeft: maxStructs}
|
||||
shape, err := sc.compileShape(t, label)
|
||||
if f.structs == nil {
|
||||
f.structs = map[reflect.Type]structResult{}
|
||||
@@ -85,6 +85,7 @@ func (s *structShape) empty() bool { return s.record == nil && len(s.nested) ==
|
||||
// rather than filled without end, and how many more structs it may walk.
|
||||
type structCompile struct {
|
||||
root *folder
|
||||
reads []string
|
||||
visiting map[reflect.Type]bool
|
||||
structsLeft int
|
||||
}
|
||||
@@ -111,7 +112,7 @@ func (sc *structCompile) compileShape(t reflect.Type, label string) (*structShap
|
||||
return nil, err
|
||||
}
|
||||
if len(c.tags) > 0 {
|
||||
if err := c.shape.compileRecord(sc.root, t, label, c.tags); err != nil {
|
||||
if err := c.shape.compileRecord(sc.root, sc.reads, t, label, c.tags); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -255,13 +256,13 @@ func checkTaggedType(sf reflect.StructField) error {
|
||||
|
||||
// compileRecord compiles the tagged fields of t as one record, and proves each column holds
|
||||
// only what its field's Go type can.
|
||||
func (s *structShape) compileRecord(root *folder, t reflect.Type, label string, tags map[string]jsonvalue.Value) error {
|
||||
func (s *structShape) compileRecord(root *folder, reads []string, t reflect.Type, label string, tags map[string]jsonvalue.Value) error {
|
||||
tags["format"] = jsonvalue.String("")
|
||||
n, err := compileFrom(jsonvalue.Object(tags), atGoTop)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", label, err)
|
||||
}
|
||||
if err := loadInline(root, n, label, true); err != nil {
|
||||
if err := loadInline(root, reads, n, label, true); err != nil {
|
||||
return err
|
||||
}
|
||||
record, err := recordOf(n)
|
||||
|
||||
Reference in New Issue
Block a user