viper监控文件变化出现两次事件
问题描述
监控配置文件变化,如果内容发生了修改,需要及时加载. 使用viper监控文件变化发现了, 对文件修改一次,会出发两次事件.
示例代码
viper.OnConfigChange(func(e fsnotify.Event) { if e.Op & fsnotify.Write != 0 { fmt.Println("Config file changed:", e.Name) } }) viper.WatchConfig()
推测原因
* 检查viper的源码是否存在bug?
未发现异常
* 两次变化viper读到的内容返回值是否不一样?
发现viper.AllKeys()返回值不一样, 一次为空, 一次正常.
* 换一个电脑试试?
发现了在公司办公电脑出现,家里电脑不会出现。
解决办法
//使用AllKeys进行过滤 viper.OnConfigChange(func(e fsnotify.Event) { if e.Op & fsnotify.Write != 0 && viper.AllKeys()>0{ fmt.Println("Config file changed:", e.Name) } }) viper.WatchConfig()
总结
公司的办公电脑安装了文件加密软件。我估摸着是它搞了个什么鬼.
2022年9月24日 00:18
Mathematics helps us understand the world and provides an effective way of building mental discipline. Math encourages logical reasoning, critical thinking, creative thinking, abstract or spatial thinking, problem-solving ability, and even effective communication. NCERT has introduced the solved question bank with sample paper suggestions for all topics of maths along with solutions. problem-solving ability, NCERT Mathematics Question Paper Class 9 and even effective communication. NCERT has introduced the solved question bank with sample paper suggestions for all topics of maths along with solutions.
2022年10月01日 20:37
Thanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family. Why inventors turn to experts like InventHelp
2022年10月03日 13:33
This service runs a plagiarism check on every single piece of writing released to our clients.
Writing tasks are very demanding and often cause imbalance between personal and educational spheres.
That is why numerous students require assistance from a professional essay writing service every day.
2022年10月13日 02:25
Lake had written involved in exact same issue, Lake can provide the hyperlink into the page. youtube downloader
2022年10月18日 13:50
PEAKERR provides best smm panel Services & cheap smm panel Services In The World. For Youtube Views Panel, TikTok Services Panel, Facebook Services Panel, Instagram Services Panel, And Many More, We Are Providing All Services At Cheap Rates For Reseller SMM Panels. Resell Our SMM Services And Make Money Online. We Have Many Free SMM Panel Services & Give You Some Test Funds For Check Our Services Quality. We Always Try to Provide High-Quality Services At a Cheap Rate. Check: https://peakerr.com/
2022年10月20日 14:01
Het strand brengt het beste in iedereen naar boven! Ga met elkaar even helemaal uit je dagelijkse omgeving. Van fysieke activiteiten tot juist tactische activiteiten en denkspellen. Het is écht geschikt voor iedereen! Om dan de dag af te sluiten in de zomer met een heerlijke BBQ of feestavond aan het strand. Stranduitjes aan de Noordhollandse en zuidhollandse stranden
2022年10月26日 16:59
This is such a great post, and was thinking much the same myself. Another great update. 바카라사이트
2022年10月26日 23:35
Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing... driving directions to the closest grocery store
2022年10月27日 01:40
This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..
2022年10月29日 00:41
These you will then see the most important thing, the application provides you a website a powerful important internet page: แทงบอล
2022年10月29日 15:37
The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface. แทงบอล
2022年10月29日 17:07
GK Digest: GK Quiz for General Knowledge, General Studies, Current Affairs and Aptitude with Interesting Questions for APPSC, Facts TSPSC, UPSC, SSC, Banking / IBPS, IAS, NTSE, CLAT, Railways, NDA, CDS, Judiciary, UPPSC, RPSC, GPSC, MPSC, MPPSC and other states civil services/government Competitive Exams in Telugu.
2022年10月30日 23:25
Thank you for the update, very nice site.. evolutionary astrologer
2022年11月01日 02:20
All online casinos offer clients great bonuses on first deposits and for setting up a new account.
The reason that online casinos offer these benefits is that they lack the enticement that comes with a physical casino’s glitzy interiors, alcoholic drinks, and chimes throughout the building.
2022年11月02日 16:49
Local and foreign investments measure a country’s economic growth. India is an upcoming, fast-growing economic hub. With thousands of foreign investors from different sectors. India Banks among the sixth-largest consumer market and best in economic progress. List of Foreign Banks in India The country attracts foreign direct investment (FDI) working in various banking and financial sectors. All foreign banks in India play a significant role. They provide financial and insurance services to everyone without discrimination.
2022年11月03日 14:14
It is somewhat fantastic, and yet check out the advice at this treat. Fenny TObaku Denpasar
2022年11月03日 16:00
I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing. seo company orange county
2022年11月03日 17:24
The YSR Bima scheme is developed to help families who lose their family breadwinner to death by accident or disability. The insurance will benefit the families of casual workers and poor state residents. YSR Bima Scheme Apply Online The government has assigned Rs.510 Crores to cater for more than 1.14 crore families in AP state. The government will deposit Rs. 1.5 lakhs in the beneficiary’s Bank account within 15 days. They will also receive Rs—10,000 as immediate financial relief.
2022年11月18日 20:45
This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work click here
2022年11月20日 02:39
Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. blc2 powder
2022年11月21日 23:23 In this case you will begin it is important, it again produces a web site a strong significant internet site: Agen Joker123
2022年11月22日 21:28
Mmm.. estimable to be here in your report or notify, whatever, I repute I should moreover process strong for my have website want I play some salubrious further updated busy in your location. Cheap kashmir packages
2022年11月25日 03:37
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. bergara b14 hunter
2022年12月23日 17:11
I’ve been absent for a while, but now I remember why I used to love this website. Thank you, I will try and check back more often. How frequently you update your site?
사설 카지노 제이나인
제이나인 소셜 카지노
카지노 게임 종류 제이나인
제이나인 카지노 먹튀 검증
호텔 카지노 제이나인
https://www.j9korea.com/
2023年1月01日 19:13
Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also sufiqawwalinetwork
2023年1月27日 15:37
<a href="https://makolastores.us/" rel="dofollow">African market near me</a></br>
<a href="https://makolastores.us/" rel="dofollow">Market African</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Products</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Food</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Black Soap</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Clothes</a></br>
<a href="https://makolastores.us/" rel="dofollow">Makola Market</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Market</a></br>
<a href="https://makolastores.us/" rel="dofollow">220 Volts Electronics</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Yam</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Groceries</a></br>
<a href="https://makolastores.us/" rel="dofollow">African print fabric</a></br>
<a href="https://makolastores.us/" rel="dofollow">African batik art</a></br>
<a href="https://makolastores.us/" rel="dofollow">African beaded jewelry</a></br>
<a href="https://makolastores.us/" rel="dofollow">Jollof Rice</a></br>
<a href="https://makolastores.us/" rel="dofollow">African Snacks</a></br>
http://plus.google.com/url?q=https://makolastores.us/
http://google.com.gh/url?q=https://makolastores.us/
http://google.gy/url?q=https://makolastores.us/
http://google.gp/url?q=https://makolastores.us/
http://google.com.gt/url?q=https://makolastores.us/
http://google.ge/url?q=https://makolastores.us/
http://google.gr/url?q=https://makolastores.us/
http://google.com.na/url?q=https://makolastores.us/
http://google.com.ng/url?q=https://makolastores.us/
http://Images.google.cd/url?q=https://makolastores.us/
http://Images.google.com.cu/url?q=https://makolastores.us/
http://Images.google.com.kw/url?q=https://makolastores.us/
http://Images.google.hr/url?q=https://makolastores.us/
http://Images.google.co.tz/url?q=https://makolastores.us/
http://Images.google.co.th/url?q=https://makolastores.us/
http://Images.google.com.tr/url?q=https://makolastores.us/
http://Images.google.tt/url?q=https://makolastores.us/
http://maps.google.com.pr/url?q=https://makolastores.us/
http://maps.google.fr/url?q=https://makolastores.us/
http://maps.google.com.fj/url?q=https://makolastores.us/
http://maps.google.fi/url?q=https://makolastores.us/
http://maps.google.com.ph/url?q=https://makolastores.us/
http://maps.google.hu/url?q=https://makolastores.us/
http://maps.google.com.au/url?q=https://makolastores.us/
http://maps.google.com.hk/url?q=https://makolastores.us/
http://Images.google.com.gh/url?q=https://makolastores.us/
http://google.lt/url?q=https://makolastores.us/
http://google.mg/url?q=https://makolastores.us/
http://google.com.my/url?q=https://makolastores.us/
http://google.com.mx/url?q=https://makolastores.us/
http://google.co.ma/url?q=https://makolastores.us/
http://google.mu/url?q=https://makolastores.us/
2023年2月07日 02:40 Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet! imr 4064
2023年2月07日 18:39
I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. assumeworld
2023年2月22日 15:48
What are you waiting for vist now.<a href="https://tamilplay.bond">https://tamilplay.bond</a> is one of the best sites out there to download latest tamil movies for free.
2023年3月01日 20:13
Steam Innovation was formed as an innovation academy to reveal kids' usual creativity and curiosity with the help of learning kits while helping parents who want to bring enriching experiences to their children. We hope monthly stem kits will produce the problem-solving skills and creative sureness that kids gain today and will help them tackle the experiments and breaks of tomorrow.
2023年3月05日 21:27
Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. Bokep
2023年3月12日 11:37
I read this article. I think You put a great deal of exertion to make this article. I like your work. Kurvana disposable
2023年3月19日 18:58
On my website you'll see similar texts, write what you think.