diff --git a/internal/config/config.go b/internal/config/config.go index d9ff5a4..adcb4a5 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -10,8 +10,8 @@ import ( ) const ( - configDirPath = "data" - configFile = "data.json" + configDirPath = "data" + configFileJSON = "data.json" ) type Config interface { @@ -39,10 +39,20 @@ type Path struct { // LoadConfig return config, configDemo func LoadConfig(path string) (*configReal, *configDemo, error) { - configPath := filepath.Join(path, configDirPath, configFile) - bytes, err := os.ReadFile(configPath) + cfgReal, cfgDemo, err := loadConfigJSON(path) + if err == nil { + return cfgReal, cfgDemo, nil + } + + return nil, nil, fmt.Errorf("failed to load config: %w", err) +} + +func loadConfigJSON(path string) (*configReal, *configDemo, error) { + configPathJSON := filepath.Join(path, configDirPath, configFileJSON) + + bytes, err := os.ReadFile(configPathJSON) if err != nil { - return nil, nil, fmt.Errorf("failed to read file%s: %w", configPath, err) + return nil, nil, fmt.Errorf("failed to read file%s: %w", configPathJSON, err) } var cfgApps configApps diff --git a/internal/config/config_real.go b/internal/config/config_real.go index 63751a7..8a57978 100644 --- a/internal/config/config_real.go +++ b/internal/config/config_real.go @@ -131,7 +131,7 @@ func getUnusedDirs(apps map[string]App) (map[string]struct{}, error) { unusedDirs := make(map[string]struct{}) for _, file := range files { // Ignore config file - if file.Name() == configFile { + if file.Name() == configFileJSON { continue }