新增获取配置文件路径函数

This commit is contained in:
zyj
2026-03-04 17:45:33 +08:00
parent 6154b30d81
commit a1237ea8f0

View File

@@ -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
}