diff --git a/internal/config/paths.go b/internal/config/paths.go index 2fbbcfa..f5b39af 100644 --- a/internal/config/paths.go +++ b/internal/config/paths.go @@ -3,6 +3,8 @@ package config import ( "os" "path/filepath" + + "github.com/spf13/viper" ) const ( @@ -55,3 +57,11 @@ func (p *Paths) EnsureDirs() error { } return nil } + +func (p *Paths) ConfigFilePath() string { + path := viper.ConfigFileUsed() // 触发 viper 加载配置文件 + if path != "" { + return path + } + return p.Config +}