From 5ad4bc05cf581ee54efd78c7fd58202609d10857 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 6 Dec 2019 14:23:11 +0100 Subject: [PATCH] Add decoder opts to unmarshal exact --- viper.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/viper.go b/viper.go index 6085590..eb2f517 100644 --- a/viper.go +++ b/viper.go @@ -949,9 +949,11 @@ func decode(input interface{}, config *mapstructure.DecoderConfig) error { // UnmarshalExact unmarshals the config into a Struct, erroring if a field is nonexistent // in the destination struct. -func UnmarshalExact(rawVal interface{}) error { return v.UnmarshalExact(rawVal) } -func (v *Viper) UnmarshalExact(rawVal interface{}) error { - config := defaultDecoderConfig(rawVal) +func UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error { + return v.UnmarshalExact(rawVal, opts...) +} +func (v *Viper) UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error { + config := defaultDecoderConfig(rawVal, opts...) config.ErrorUnused = true err := decode(v.AllSettings(), config)