Skip to content

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

Description

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

}

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions