Validating configurations files with viper


I was looking for a configuration parser for go and seems to come highly recommended.

I am very surprised to find that configuration files are not validated by default.
Viper parses files and extracts requested values from them but I cannot find a way to detect bad configuration.

For instance I if create a (Java style) .properties file containing just “???” and nothing else. This is accepted without any error.

I can understand the philosophy that you should ignore irrelevant configuration items but I desire more rigor. I would also like to reject anything that does not match the X=Y format in a properties file.

To me this is a fatal flaw that suggests I should use a different package (or roll my own as usual).

Have I missed something? Does viper in fact support detecting and rejecting bad configuration keys?


I think the answer is no. viper does not validate java .properties files.
I posted a bug report (or feature request depending on your point of view) as

Answered By – Bruce Adams

Answer Checked By – Robin (GoLangFix Admin)

Leave a Reply

Your email address will not be published.