使用qoder优化后更新
Some checks failed
Go build / build and run (push) Has been cancelled

This commit is contained in:
2026-02-12 13:48:35 +08:00
parent abd5962ae9
commit bc59f616fd
15 changed files with 130 additions and 278 deletions

View File

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