防止绝对路径被编译进二进制文件
This commit is contained in:
@@ -9,12 +9,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_, b, _, _ = runtime.Caller(0)
|
Root string
|
||||||
Root = filepath.Join(filepath.Dir(b), "..")
|
Viper *viper.Viper
|
||||||
Viper *viper.Viper
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
_, b, _, _ := runtime.Caller(0)
|
||||||
|
Root = filepath.Join(filepath.Dir(b), "..")
|
||||||
config_file := filepath.Join(Root, "data", "config.yaml")
|
config_file := filepath.Join(Root, "data", "config.yaml")
|
||||||
viper.SetConfigFile(config_file)
|
viper.SetConfigFile(config_file)
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
|
Reference in New Issue
Block a user