diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-10 19:38:06 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-10 19:38:06 +0200 |
| commit | 526c3f0ed139bbacaa415154a272d96279d26239 (patch) | |
| tree | 3754e0b969b47761583ec408e02ea45a7185ad71 /internal/appconfig/config_defaults.go | |
| parent | 07115c22a74dd5311f70434029791d5346e627c4 (diff) | |
task 80330fc4: deduplicate default config path helper
Diffstat (limited to 'internal/appconfig/config_defaults.go')
| -rw-r--r-- | internal/appconfig/config_defaults.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/appconfig/config_defaults.go b/internal/appconfig/config_defaults.go new file mode 100644 index 0000000..80ba697 --- /dev/null +++ b/internal/appconfig/config_defaults.go @@ -0,0 +1,17 @@ +package appconfig + +const configPathFallback = "$XDG_CONFIG_HOME/hexai/config.toml" + +// DefaultConfigPath returns the resolved config path or the documented XDG +// fallback when the real path cannot be determined. +func DefaultConfigPath() string { + return configPathOrFallback(ConfigPath) +} + +func configPathOrFallback(resolve func() (string, error)) string { + path, err := resolve() + if err != nil { + return configPathFallback + } + return path +} |
