We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When calling viper.SafeWriteCofig() it fails with a file not found error.
Test code attached.
package main import ( "fmt" "os" "github.com/spf13/viper" ) func main() { viper.AddConfigPath("/tmp") viper.SetConfigName("filename") viper.SetConfigType("yaml") viper.SetDefault("LogLevel", "Info") fmt.Println("Writing Config file!") err := viper.SafeWriteConfig() if err != nil { fmt.Println(err) os.Exit(1) } fmt.Println("wrote config file") }
Output:
Writing Config file! Config File "filename" Not Found in "[/tmp]"
Expected output:
Write Config file! wrote config file
The text was updated successfully, but these errors were encountered:
+1
Currently the documentation for SafeWriteConfig is quite misleading 😅
SafeWriteConfig writes current configuration to file only if the file does not exist.
This is issue is also present for SafeWriteConfigAs
Sorry, something went wrong.
SafeWriteConfig
This is fixed in #450
Use viper.SetConfigFile("filename.yaml") instead of viper.SetConfigName("filename") then SafeWriteConfig and SafeWriteConfigAs() will work
No branches or pull requests
When calling viper.SafeWriteCofig() it fails with a file not found error.
Test code attached.
Output:
Expected output:
The text was updated successfully, but these errors were encountered: