Skip to content
Leszek Cimała edited this page Jan 25, 2019 · 2 revisions

Tips and tricks

Let's collect some more or less obvious tips here.

Customized unmarshaling

If you need to customize unmarshaling look at mapstructure config options and you can set it like that:

// if you need error on unknown fields in your config file
viper.Unmarshal(&f.d, func(config *mapstructure.DecoderConfig) {                                                          
        config.ErrorUnused = true                                                                                                    
    })

Clone this wiki locally