go-gin-api icon indicating copy to clipboard operation
go-gin-api copied to clipboard

viper监听配置文件修改的时候,变量读和写,在不同的线程,这里是否要加锁

Open 1426919587 opened this issue 11 months ago • 0 comments

viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) {
            //写数据
	if err := viper.Unmarshal(config); err != nil {
		panic(err)
	}
})

}

func Get() Config { //读数据 return *config }

1426919587 avatar Feb 29 '24 03:02 1426919587