diff --git a/internal/config/config.go b/internal/config/config.go index ff375951..c307613a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,6 +14,7 @@ import ( //go:embed config.toml var DefaultConfig string +var Path = filepath.Join(dirs.Config, "config.toml") type Environment map[string]string @@ -38,18 +39,16 @@ type Config struct { func Load() Config { var cfg Config - path := filepath.Join(dirs.Config, "config.toml") - // This is a default hard-coded configuration. It should not fail. _, _ = toml.Decode(DefaultConfig, &cfg) - if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { + if _, err := os.Stat(Path); errors.Is(err, os.ErrNotExist) { log.Println("Using default configuration") return cfg } - if _, err := toml.DecodeFile(path, &cfg); err != nil { + if _, err := toml.DecodeFile(Path, &cfg); err != nil { log.Printf("Failed to load configuration: %s, using default configuration", err) }