From 7943c42d9c376506c685dcf73ad5dd54052e135c Mon Sep 17 00:00:00 2001 From: ajatprabha Date: Thu, 11 Jan 2024 09:44:38 +0530 Subject: [PATCH] add examples --- xload/providers/viper/example_test.go | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/xload/providers/viper/example_test.go b/xload/providers/viper/example_test.go index d9d3f55..fd9767d 100644 --- a/xload/providers/viper/example_test.go +++ b/xload/providers/viper/example_test.go @@ -37,3 +37,55 @@ func ExampleNew() { // Output: // debug } + +func ExampleFrom() { + _, err := viper.New(viper.From(vpr.New())) + if err != nil { + panic(err) + } +} + +func ExampleLoader_ConfigFileUsed() { + _, err := viper.New(viper.ConfigFile(".ext")) + if err != nil { + panic(err) + } + + fmt.Println(vpr.ConfigFileUsed()) // .ext +} + +func ExampleNew_fileOptions() { + _, err := viper.New( + viper.ConfigName("config"), + viper.ConfigType("toml"), + viper.ConfigPaths([]string{"./", "/etc/