From eb876e1a159f4c5bae7fe181accd94dc6d21d5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=9E=E4=BF=AE=E6=98=8E?= <1034552569@qq.com> Date: Mon, 30 Aug 2021 14:48:16 +0800 Subject: [PATCH] update readme.md ```go viper.WatchConfig() viper.OnConfigChange(func(e fsnotify.Event) { fmt.Println("Config file changed:", e.Name) }) ``` this code will cause data race, please check this question: https://stackoverflow.com/questions/68915944/viper-dynamically-loading-config-file-has-data-race/68919971#68919971 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e3986f7..97654df 100644 --- a/README.md +++ b/README.md @@ -175,10 +175,10 @@ Optionally you can provide a function for Viper to run each time a change occurs **Make sure you add all of the configPaths prior to calling `WatchConfig()`** ```go -viper.WatchConfig() viper.OnConfigChange(func(e fsnotify.Event) { fmt.Println("Config file changed:", e.Name) }) +viper.WatchConfig() ``` ### Reading Config from io.Reader