新增获取配置文件路径函数
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user