(templatesDir string)
| 345 | } |
| 346 | |
| 347 | func loadTemplateOverrides(templatesDir string) (map[string]string, error) { |
| 348 | templates := make(map[string]string) |
| 349 | |
| 350 | if templatesDir == "" { |
| 351 | return templates, nil |
| 352 | } |
| 353 | |
| 354 | files, err := os.ReadDir(templatesDir) |
| 355 | if err != nil { |
| 356 | return nil, err |
| 357 | } |
| 358 | |
| 359 | for _, f := range files { |
| 360 | // Recursively load subdirectory files, using the path relative to the templates |
| 361 | // directory as the key. This allows for overriding the files in the service-specific |
| 362 | // directories (e.g. echo, chi, fiber, etc.). |
| 363 | if f.IsDir() { |
| 364 | subFiles, err := loadTemplateOverrides(path.Join(templatesDir, f.Name())) |
| 365 | if err != nil { |
| 366 | return nil, err |
| 367 | } |
| 368 | for subDir, subFile := range subFiles { |
| 369 | templates[path.Join(f.Name(), subDir)] = subFile |
| 370 | } |
| 371 | continue |
| 372 | } |
| 373 | data, err := os.ReadFile(path.Join(templatesDir, f.Name())) |
| 374 | if err != nil { |
| 375 | return nil, err |
| 376 | } |
| 377 | templates[f.Name()] = string(data) |
| 378 | } |
| 379 | |
| 380 | return templates, nil |
| 381 | } |
| 382 | |
| 383 | // detectPackageName detects and sets PackageName if not already set. |
| 384 | func detectPackageName(cfg *configuration) error { |
no outgoing calls
no test coverage detected
searching dependent graphs…