Files
terminar 13801bec11 Add platform-independent path/config resolution library
Implements core/paths (Config/Data/State/Cache/Runtime/Log/Bin
directory resolution with canonical-vs-search-dir separation, XDG on
Unix, native APPDATA/LOCALAPPDATA/PROGRAMDATA layering on Windows,
~/Library on macOS Desktop, injectable environment/platform for
deterministic cross-platform tests) and core/config (file search,
first-match resolution, layered YAML merging, safe ${VAR} expansion,
Explain/doctor introspection) on top of the shared Application/
Kind/Scope model in the core package.
2026-09-19 16:26:01 +02:00

26 lines
770 B
Go

package config
// Resolve returns the highest-priority existing configuration file
// (spec section 25). found is false if no layer's file exists -- this is
// not an error; callers decide whether "no configuration file" is fine.
func (r *Resolver) Resolve() (layer Layer, found bool, err error) {
all, err := r.layers()
if err != nil {
return Layer{}, false, err
}
for _, l := range all {
if l.Exists {
return l, true, nil
}
}
return Layer{}, false, nil
}
// ResolveAll returns every layer in the priority hierarchy, highest
// priority first, whether or not the file exists there (spec section
// 26) -- e.g. for a `doctor`-style report of every location that was
// considered.
func (r *Resolver) ResolveAll() ([]Layer, error) {
return r.layers()
}