gin支持prometheus
全局gin对象如何在子模块中修改Logger

viper监控文件变化出现两次事件

妙音 posted @ 2022年9月17日 20:03 in golang with tags viper golang , 1255 阅读
 
问题描述
 
监控配置文件变化,如果内容发生了修改,需要及时加载. 使用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()
 
 

总结

 
公司的办公电脑安装了文件加密软件。我估摸着是它搞了个什么鬼.
 
 
 
 
 
Avatar_small
Website 说:
2023年6月13日 01:52

Buy Instagram PVA Accounts in bulk from us. Our Old Instagram PVA accounts are great for the Growth of Business Profiles.

Avatar_small
Johny 说:
2023年6月15日 23:26

Beaver says I also have such interest, you can read my profile here: 롸쓰고 고객센터

Avatar_small
Website 说:
2023年7月06日 03:29

Boost your social media strategy with our buy bulk Instagram accounts. Reach a wider audience and effortlessly expand your online presence.

Avatar_small
SEO 说:
2023年7月06日 20:30

I personally use them exclusively high-quality elements : you will notice these folks during: 우리카지노

Avatar_small
shafi 说:
2023年7月10日 00:09

This is actually to boot the most fantastic post we tend to earnestly veteran researching throughout. It happens to be definitely not consistently we've found financial risk view a little. 數學補習社

Avatar_small
jack 说:
2023年7月11日 16:02

I might suggest solely beneficial in addition to trusted facts, and so find it: <a href="https://www.upwork.com/freelancers/muhammadm191">SEO</a>

Avatar_small
zafar 说:
2023年7月13日 13:45

Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! 裝修設計

Avatar_small
shafi 说:
2023年7月16日 18:53

An impressive share, I simply with all this onto a colleague who had previously been conducting a little analysis about this. And hubby in reality bought me breakfast since I ran across it for him.. smile. So well then, i’ll reword that: Thnx for the treat! But yeah Thnkx for spending any time to debate this, I find myself strongly about it and really like reading regarding this topic. If you can, as you become expertise, can you mind updating your blog with increased details? It truly is highly great for me. Huge thumb up with this blog post! Heets. IQOS

Avatar_small
shafi 说:
2023年7月17日 13:26

An interesting discussion may be valued at comment. I believe that you need to write more on this topic, may well be described as a taboo subject but typically folks are insufficient to speak on such topics. Yet another. Cheers Heets. IQOS

Avatar_small
shafi 说:
2023年7月18日 18:13

whoah this blog is excellent i love reading your posts. Stay up the good work! You realize, lots of people are looking around for this info, you can help them greatly. Heets

Avatar_small
shafi 说:
2023年7月18日 23:00

Wow I absolutely love her! She is so darn beautiful on top of being a really good actor. I don’t think the show V is all that good, however I watch it anyway just so I can see her. And I don’t know if you’ve ever seen her do an interview but she is also rather funny and its all so natural for her. I personally never even heard of her before The V, now I’ll watch anything she’s on. Heets

Avatar_small
shafi 说:
2023年7月19日 21:23

There couple of intriguing points in time in this post but I do not know if I see these people center to heart. There is some validity but I most certainly will take hold opinion until I investigate it further. Great post , thanks and we want more! Included in FeedBurner likewise Couch dispose Berlin

Avatar_small
shafi 说:
2023年7月22日 18:42

Thanks for sharing your ideas. I would also like to say that video games have been actually evolving. Technology advances and improvements have aided create reasonable and interactive games. These kind of entertainment video games were not actually sensible when the real concept was first of all being used. Just like other forms of technologies, video games as well have had to grow by means of many many years. This itself is testimony for the fast continuing development of video games. https://casinostars.se

Avatar_small
shafi 说:
2023年7月23日 02:04

magnificent issues altogether, you simply won emblem reader. What may you suggest in regards to your put up that you just made a few days in the past? Any positive? order polkadot chocolate

Avatar_small
shafi 说:
2023年7月23日 22:44

I was just looking for this info for some time. After six hours of continuous Googleing, at last I got it in your site. I wonder what is the lack of Google strategy that don’t rank this type of informative web sites in top of the list. Normally the top websites are full of garbage. فیلم سکسی

Avatar_small
shafi 说:
2023年7月24日 16:53

Hello! I recently wish to give a enormous thumbs up for your great information you’ve got here for this post. I’ll be coming back to your website for additional soon. How to Fix a Slow Flushing Toilet

Avatar_small
jack 说:
2023年7月25日 18:59

Why do only so much written on this subject? Here you see more. <a href="https://www.upwork.com/freelancers/muhammadm191">backlink</a>

Avatar_small
shafi 说:
2023年7月26日 18:33

I have been absent for some time, but now I remember why I used to love this website. Thanks , I’ll try and check back more often. How frequently you update your web site? https://www.cruxfinder.com/

Avatar_small
Imamia Quran Academy 说:
2023年7月27日 06:04

Nice blog. I enjoyed reading your articles. This is truly a great read for me. I am from Imamia Quran Academy. Our Online Shia Quran Academy is a comprehensive institution with full fledged facilities regarding Shia Quran Learning. Shia Online Learning more efficiently saves time and money spent over conveyance and physical going to any conventional Shia Quran Institute.

Avatar_small
shafi 说:
2023年7月29日 13:17

But the unimaginative writers couldn’t be bothered to work out a plot consistent with the all the rest of the Star Trek collection. 먹튀폴리스 사나이 추천인

Avatar_small
seo 说:
2023年7月29日 17:00

Awesome and interesting article. Great things you've always shared with us. Thanks. Just continue composing this kind of post. buy weller bourbon

Avatar_small
shafi 说:
2023年7月29日 18:37

Its gathered on your site even though reducing popularity merely quite a few tid tiny bit submits. Enjoyable technique for impending, I'll be book-marking before starting purchase products and solutions final result spgs up right up. 먹튀폴리스 이브벳 검증

Avatar_small
shafi 说:
2023年7月30日 17:13

After i bought against your site however adding desire only marginally touch submits. Exciting way of permanent, Soon we will be book-marking each time get hold of styles entire can come in place. slot88 online

Avatar_small
six components of he 说:
2023年8月09日 16:32

This is by far the best explanation I've come across on this topic. Thank you!

Avatar_small
Reelz Production Hou 说:
2023年8月10日 16:23

When it comes to discovering the perfect platform for your talent in Delhi, the city's top casting agencies, including the esteemed Reelz Production House, stand as pillars of opportunity. Their knack for identifying the right fit between actors and roles is truly remarkable. A reliable choice for anyone aspiring to shine in the entertainment spotlight within Delhi's thriving creative arena.

Avatar_small
Car tyre inflator 说:
2023年8月10日 17:09

The tyre inflator for car has proven to be an indispensable companion for my journeys. It's a real game-changer when it comes to maintaining optimal tire pressure. Whether it's a road trip or just daily commuting, having a tyre inflator for car in my trunk gives me a sense of security. It's straightforward to use and has saved me from inconvenient stops at gas stations. With the tyre inflator for car, I'm always in control of my tire health, ensuring a smooth and worry-free drive every time.

Avatar_small
Interdental Toothbru 说:
2023年8月10日 23:15

The Interdental Toothbrush has completely transformed my dental care routine. Its innovative design allows me to thoroughly clean between my teeth, where traditional brushing often falls short. The Interdental Toothbrush has become a must-have tool for me, ensuring a deeper and more effective clean. I've noticed a remarkable improvement in my gum health and overall oral hygiene since incorporating the Interdental Toothbrush into my daily routine. It's a small investment that has yielded significant rewards, and I highly recommend the Interdental Toothbrush to everyone seeking a healthier smile.

Avatar_small
Battery Recycling 说:
2023年8月11日 01:10

Battery recycling is an essential practice for a cleaner environment. Through battery recycling, we can reduce waste and minimize the harmful impact of batteries on our ecosystem. Participating in battery recycling programs ensures that used batteries are properly disposed of and valuable materials are reclaimed. Let's prioritize Battery Recycling to protect our planet and create a more sustainable future for generations to come.

Avatar_small
forex market 说:
2023年8月11日 21:41

I’m curious to find out what blog system you happen to be working with? I’m having some minor security problems with my latest site and I would like to find something more risk-free. Do you have any solutions? اقامة مستثمر في دبي

Avatar_small
Battery Raw Material 说:
2023年8月14日 14:36

Battery raw materials are the unsung heroes powering our modern lives. Elements like lithium, cobalt, and nickel might seem ordinary, but they're the secret behind our gadgets and electric vehicles. These materials work tirelessly behind the scenes, storing and releasing energy in our batteries. As technology advances, the responsible sourcing and recycling of battery raw materials become increasingly important. Let's appreciate these vital components and work towards a sustainable future where our devices and transportation are powered by eco-friendly choices.

Avatar_small
Orthodontic Brush 说:
2023年8月14日 16:38

The orthodontic brush has been a game-changer for my dental hygiene routine. With braces, cleaning around the wires and brackets used to be a challenge. But the orthodontic brush's specially designed bristles and shape make it so much easier to reach those areas. It gives me confidence that I'm maintaining a thorough clean even with orthodontic appliances. It's become an essential tool in my daily routine, and I'm grateful for the difference it's made in keeping my smile healthy during my orthodontic journey.

Avatar_small
Car Accessories Onli 说:
2023年8月14日 21:14

Car Accessories Online has been a game-changer for me. The convenience of exploring a wide array of accessories from the comfort of my home is unbeatable. I've found everything I need to enhance my driving experience, from practical gadgets to stylish upgrades. It's like having a one-stop shop for all my car customization needs. The range of options and the ease of ordering have truly exceeded my expectations. Thanks to Car Accessories Online, my car is now not only more functional but also a reflection of my personal style.

Avatar_small
Buy Car Accessories 说:
2023年8月16日 17:55

Buy Car Accessories Online has transformed my vehicle into a personalized masterpiece. The convenience and variety of options available are unbeatable. Highly recommended for anyone looking to upgrade their ride with ease.

Avatar_small
Interdental Brush 说:
2023年8月17日 00:25

Interdental brushes are a must-have for maintaining optimal oral hygiene. They effectively remove plaque and food particles from between teeth, preventing damage to gums and enamel. Using interdental brushes alongside regular brushing can significantly improve oral health.

Avatar_small
Reelz Production Hou 说:
2023年8月17日 02:31

I completely agree that Reelz Production House is one of the best modeling agencies in Delhi. Their commitment to nurturing and guiding aspiring models is truly commendable. From talent development to portfolio building, casting assistance, and career management, they offer a comprehensive range of services that cater to every aspect of a model's journey. The personalized guidance and attention to detail provided by their team of industry experts sets them apart from the rest. If you're looking for a reliable and reputable agency to kickstart your modeling career in Delhi, Reelz Production House is definitely the one to consider.

Avatar_small
forex market 说:
2023年8月17日 21:42

Hi! Someone in my Facebook group shared this site with us so I came to take a look. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers! Terrific blog and fantastic style and design. اقامة مستثمر في دبي

Avatar_small
forex market 说:
2023年8月19日 14:52

I am frequently to blogging we genuinely appreciate your content regularly. Your content has really peaks my interest. I am about to bookmark your internet site and keep checking choosing data. judi online

Avatar_small
forex market 说:
2023年8月20日 17:17

You really make it seem so easy with your presentation but I find this topic to be really something that I think I would never understand. It seems too complex and extremely broad for me. I’m looking forward for your next post, I’ll try to get the hang of it! UFABETแทงบอลบนมือถือ

Avatar_small
forex market 说:
2023年8月21日 19:44

Nice post. I discover some thing much harder on different blogs everyday. Most commonly it is stimulating to learn content from other writers and use a little there. I’d choose to apply certain with the content on my own weblog regardless of whether you don’t mind. Natually I’ll provide link on the web weblog. Thanks for sharing. UFABETแทงบอลทายผลผู้ชนะ

Avatar_small
forex market 说:
2023年8月23日 18:31

An impressive share, I simply with all this onto a colleague who was simply carrying out a little analysis for this. And that he in truth bought me breakfast since I ran across it for him.. smile. So i want to reword that: Thnx for the treat! But yeah Thnkx for spending some time to talk about this, I feel strongly concerning this and love reading regarding this topic. Whenever possible, as you become expertise, do you mind updating your blog post with an increase of details? It truly is highly a good choice for me. Big thumb up due to this post! 메이저사이트

Avatar_small
forex market 说:
2023年8月24日 14:27

I enjoy every single posts, I actually appreciated, I would personally adore extra information and facts because of this, mainly because its fairly pleasing., Have fun here ideal for allowing. UFABET เว็บพนันแตกง่าย

Avatar_small
forex market 说:
2023年8月24日 23:18

There is noticeably a lot of money to know about this. I suppose you’ve made particular nice points in functions also. เว็บไซต์แทงบอลอันดับ1

Avatar_small
forex market 说:
2023年8月25日 21:06

Simply this site is likely to irrefutably quite possibly possibly be renowned affecting quite a few information sites person's, to help it is conscientious content pieces or it could be viewpoints. เว็บพนันออนไลน์UFA

Avatar_small
forex market 说:
2023年8月26日 20:02

When i benefit your existing document. It might be top notch to examine everyone reveal with text throughout the coronary heart in conjunction with lucidity due to this vital difficulty may very well be easily viewed. UFABETทางเข้าหลักเว็บแทงบอล

Avatar_small
forex market 说:
2023年8月27日 00:10

I favor the actual publish. It truly is superb to discover a person explain in words out of your cardiovascular as well as high quality with this particular essential subject material might be very easily observed. UFABETเว็บพนันถูกกฎหมายต่างประเทศ

Avatar_small
forex market 说:
2023年8月27日 15:55

Easily that website can certainly irrefutably gain popularity concerning nearly all blogs in addition to site-building men and women, to help it is diligent threads as well as assessments. UFABETเว็บพนันบอลออนไลน์ฟรีเครดิต

Avatar_small
forex market 说:
2023年8月27日 19:46

Simply this site is likely to irrefutably quite possibly possibly be renowned affecting quite a few information sites person's, to help it is conscientious content pieces or it could be viewpoints. ลิงค์ทางเข้าหลักUFABET

Avatar_small
forex market 说:
2023年8月28日 16:25

As i purchased with your blog site while positioning fascination purely a little bit little submits. Fulfilling technique for extended, We will be book-marking during a period attain forms finish happens further up. สมัครเล่นพนันบอลUFABET

Avatar_small
Johny 说:
2023年8月28日 20:00

Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. familie vakantie naar mozaga

Avatar_small
forex market 说:
2023年8月29日 00:02

Useful info. Fortunate me I discovered your web site by accident, and I’m surprised why this coincidence did not came about earlier! I bookmarked it. สูตรแทงบอลเว็บUFABET

Avatar_small
forex market 说:
2023年8月29日 16:57

Instantly that web site could possibly irrefutably finish up popular concerning just about every publishing some people, on account of conscientious articles or blog posts in addition to opinions in addition to reviews. UFABETเว็บแทงบอลออนไลน์ถูกกฏหมาย

Avatar_small
SEO 说:
2023年8月29日 21:02

This is very interesting content! I have thoroughly enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great. Avaliador Premiado

Avatar_small
storepva 说:
2023年8月31日 12:19

I'm able to see that you are an professional at your discipline! I am happy to study this text. I assume this may beneficial and informative subject matter for everyone. That is such a nice post. I have been impressed with the aid of the specific content. I loved your put up and were given a few top ideas for it.
<a href="https://storepva.com/buy-instagram-pva-accounts/">Buy Instagram pva accounts</a>

Avatar_small
forex market 说:
2023年9月04日 22:00

Hello, i believe that i saw you visited my web site so i came to “return the prefer”.I’m attempting to to find things to improve my web site!I guess its adequate to use a few of your ideas!! salingsilang

Avatar_small
Johny 说:
2023年9月09日 00:07

Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! pentaslot

Avatar_small
sdsds 说:
2023年9月11日 14:17

I love to most of the information, I must claim when i liked, When i would love additional information related to that, because it's very good., Appreciate it about unveiling. taktik88

Avatar_small
SEO 说:
2023年9月12日 20:51

We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. croxyproxy

Avatar_small
Balloon Decoration 说:
2023年9月14日 17:06

Balloon decoration adds an extra dose of joy and vibrancy to any celebration, turning ordinary spaces into enchanting wonderlands. Whether it's a birthday bash, a wedding reception, or a corporate event, the artful arrangement of colorful balloons can instantly uplift the atmosphere. From elegant balloon arches and whimsical balloon bouquets to intricate balloon centerpieces, the possibilities are endless. And with the delightful addition of "giftlaya," a clever fusion of balloons and gifts, you can surprise your loved ones with presents tucked within beautifully adorned balloons, making any occasion truly special and memorable. Elevate your event with the magic of balloon decoration and giftlaya, creating lasting memories and smiles all around.

Avatar_small
acim app 说:
2023年9月17日 18:43

Thank you so much for the post you do. I like your post and all you share with us is up to date and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. acim app

Avatar_small
Lithium Ion Battery 说:
2023年9月18日 23:06

Lithium-ion batteries are a transformative energy storage technology, powering everything from smartphones to electric vehicles. Their high energy density, lightweight design, and rechargeable nature make them essential in our modern world. However, managing their lifespan and safety remains a challenge, with ongoing research focused on improving efficiency and sustainability in these critical power sources.

Avatar_small
sdsds 说:
2023年9月23日 00:20

Thanks for making the effort to go over this particular, Personally i think highly about this as well as adore understanding more on this topic. If at all possible, as you gain knowledge, would you mind updating your blog with more info? It is very helpful for me personally. https://community.tableau.com/s/profile/0058b00000HpydXAAR

Avatar_small
sdsds 说:
2023年9月23日 20:58

Hi! I just wanted to ask if you ever have any problems with hackers? My last blog (wordpress) was hacked and I ended up losing months of hard work due to no back up. Do you have any solutions to protect against hackers? shillong teer common number


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter