Ah cool thanks. That did it!

Cheers!


On Monday, September 11, 2017 at 12:12:27 PM UTC+12, Bojan Delic wrote:
>
> You should not use SetConfigFile. Its documentation says:
>
>> SetConfigFile explicitly defines the path, name and extension of the 
>> config file.
>> Viper will use this and not check any of the config paths.
>
> You should use SetConfigName instead and pass it "settings", without 
> extension. Its documentation says:
>
>> SetConfigName sets name for the config file.
>> Does not include extension. 
>
>
> I hope this helps. 
>
> On Sunday, September 10, 2017 at 2:05:40 AM UTC+2, Tim Uckun wrote:
>>
>> I have this code
>>
>>         v := viper.New()
>> v.SetConfigFile("settings.yaml")
>> v.AddConfigPath(".")
>>         v.AddConfigPath("./settings")
>> v.AddConfigPath("./config")
>> err := v.ReadInConfig()
>> if err != nil {
>> panic(fmt.Errorf("Error when reading config: %v\n", err))
>> }
>>
>> if as the instructions say I don't put the file extension in the 
>> SetConfigFile it fails and says it doesn't recognize the type "". so I am 
>> specifying the full name of the file.
>>
>> If I put this in the "." directory (same directory as my go file) it works
>>
>> if I put the file in the config or the settings or config directories it 
>> doesn't work and gives me the following error
>>
>>
>> panic: Error when reading config: open settings.yaml: no such file or 
>> directory
>>
>> How do I specify a relative path to viper?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to