This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
/*
|
||||
@Time : 2020/6/28 21:48
|
||||
@Author : xuyiqing
|
||||
@File : config.py
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
@@ -57,7 +51,7 @@ type Config struct {
|
||||
Security SecurityConfig
|
||||
}
|
||||
|
||||
var globalConfig *Config // 新增全局配置变量
|
||||
var globalConfig *Config
|
||||
|
||||
func LoadConfig(configPath string) (*Config, error) {
|
||||
// 1. 基础配置
|
||||
@@ -84,10 +78,9 @@ func LoadConfig(configPath string) (*Config, error) {
|
||||
return nil, fmt.Errorf("读取配置文件失败: %w", err)
|
||||
}
|
||||
|
||||
//监控并重新读取配置文件
|
||||
// 监控配置文件变更
|
||||
viper.WatchConfig()
|
||||
viper.OnConfigChange(func(e fsnotify.Event) {
|
||||
// 配置文件发生变更之后会调用的回调函数
|
||||
fmt.Println("Config file changed:", e.Name)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user