docs: add section about decoding formats

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
Mark Sagi-Kazar 2021-06-25 14:49:58 +02:00
parent a02f9864fa
commit 030b739e60
No known key found for this signature in database
GPG key ID: 31AB0439F4C5C90E

View file

@ -778,6 +778,15 @@ if err != nil {
Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshaling values which uses `mapstructure` tags by default. Viper uses [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) under the hood for unmarshaling values which uses `mapstructure` tags by default.
### Decoding custom formats
A frequently requested feature for Viper is adding more value formats and decoders.
For example, parsing character (dot, comma, semicolon, etc) separated strings into slices.
This is already available in Viper using mapstructure decode hooks.
Read more about the details in [this blog post](https://sagikazarmark.hu/blog/decoding-custom-formats-with-viper/).
### Marshalling to string ### Marshalling to string
You may need to marshal all the settings held in viper into a string rather than write them to a file. You may need to marshal all the settings held in viper into a string rather than write them to a file.