From 2636060878bb94b0ab629a5030a6352355e204c4 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Tue, 4 Jun 2024 15:16:57 +0200 Subject: [PATCH] feat: add experimental finder option Signed-off-by: Mark Sagi-Kazar --- finder.go | 7 +++++++ viper.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/finder.go b/finder.go index ab4b595..3944370 100644 --- a/finder.go +++ b/finder.go @@ -13,6 +13,13 @@ func WithFinder(f Finder) Option { }) } +// ExperimentalFinder tells Viper to use the new Finder interface for finding configuration files. +func ExperimentalFinder() Option { + return optionFunc(func(v *Viper) { + v.experimentalFinder = true + }) +} + // Finder looks for files and directories in an [afero.Fs] filesystem. type Finder interface { Find(fsys afero.Fs) ([]string, error) diff --git a/viper.go b/viper.go index 472fd59..81a62b9 100644 --- a/viper.go +++ b/viper.go @@ -194,6 +194,8 @@ type Viper struct { // TODO: should probably be protected with a mutex encoderRegistry *encoding.EncoderRegistry decoderRegistry *encoding.DecoderRegistry + + experimentalFinder bool } // New returns an initialized Viper instance.