防止绝对路径被编译进二进制文件

This commit is contained in:
2023-12-02 22:56:56 +08:00
parent 429ad157d6
commit 6590fcbb11

View File

@@ -9,12 +9,13 @@ import (
)
var (
_, b, _, _ = runtime.Caller(0)
Root = filepath.Join(filepath.Dir(b), "..")
Viper *viper.Viper
Root string
Viper *viper.Viper
)
func init() {
_, b, _, _ := runtime.Caller(0)
Root = filepath.Join(filepath.Dir(b), "..")
config_file := filepath.Join(Root, "data", "config.yaml")
viper.SetConfigFile(config_file)
if err := viper.ReadInConfig(); err != nil {