knadh / koanf

Simple, extremely lightweight, extensible, configuration management library for Go. Support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to stop file watcher?

halturin opened this issue · comments

couldn't find a way to stop file-watching.

f := file.Provider("somefile.yaml"))

f.Watch(func(event any, e error) error {
  // handler
}

am I missing something?

You're right, there's no way to currently stop watching files. Please feel free to send a PR. Perhaps an f.Unwatch().

not sure if I have enough spare time in the near future. but if I implemented this feature, I would update the Provider interface by adding

Watch(func(...) error) error // returns error if doesn't support
Unwatch() error // same here

methods to make it more unified

Hi @knadh ,
If this issue is still open would you mind taking a look at my PR #245.
I have tried implementing the unwatch function for file provider.
let me know if you feel any changes are to be made...