Skip to content

Commit da255c9

Browse files
committed
refactor(docs): simplify assignDefaults function by removing unnecessary parameter
1 parent daa4552 commit da255c9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cmd/configdocsgen/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ func integrateDefaults(parsedConfigs []ParsedConfig, defaults map[string]interfa
370370
}
371371

372372
// Recursive function to build paths and assign defaults
373-
var assignDefaults func(currentFields *[]ConfigField, currentPathPrefix string, currentStructName string)
374-
assignDefaults = func(currentFields *[]ConfigField, currentPathPrefix string, currentStructName string) {
373+
var assignDefaults func(currentFields *[]ConfigField, currentPathPrefix string)
374+
assignDefaults = func(currentFields *[]ConfigField, currentPathPrefix string) {
375375
for i := range *currentFields {
376376
field := &(*currentFields)[i] // Pointer to modify the field
377377

@@ -413,7 +413,7 @@ func integrateDefaults(parsedConfigs []ParsedConfig, defaults map[string]interfa
413413
if nestedStructInfo, isStruct := otherConfigs[field.Type]; isStruct {
414414
log.Printf("Recursing for nested struct field %s (type %s) with path prefix %s", field.Name, field.Type, field.Name)
415415
// The prefix for the children of this field is the field's own name.
416-
assignDefaults(&nestedStructInfo.Fields, field.Name, field.Type)
416+
assignDefaults(&nestedStructInfo.Fields, field.Name)
417417
} else {
418418
log.Printf("No direct default found for %s (path key: %s)", field.Name, defaultPathKey)
419419
}
@@ -422,7 +422,7 @@ func integrateDefaults(parsedConfigs []ParsedConfig, defaults map[string]interfa
422422
}
423423

424424
// Start with the top-level config, no prefix for its direct fields
425-
assignDefaults(&topLevelConfig.Fields, "", topLevelConfig.GoStructName)
425+
assignDefaults(&topLevelConfig.Fields, "")
426426

427427
// After processing top-level, some nested structs might have had their defaults assigned
428428
// by the recursion above if their parent field was processed.

0 commit comments

Comments
 (0)