MCPcopy
hub / github.com/spf13/viper / UnmarshalExact

Method UnmarshalExact

viper.go:1039–1057  ·  view source on GitHub ↗
(rawVal any, opts ...DecoderConfigOption)

Source from the content-addressed store, hash-verified

1037}
1038
1039func (v *Viper) UnmarshalExact(rawVal any, opts ...DecoderConfigOption) error {
1040 config := v.defaultDecoderConfig(rawVal, opts...)
1041 config.ErrorUnused = true
1042
1043 keys := v.AllKeys()
1044
1045 if v.experimentalBindStruct {
1046 // TODO: make this optional?
1047 structKeys, err := v.decodeStructKeys(rawVal, opts...)
1048 if err != nil {
1049 return err
1050 }
1051
1052 keys = append(keys, structKeys...)
1053 }
1054
1055 // TODO: struct keys should be enough?
1056 return decode(v.getSettings(keys), config)
1057}
1058
1059// BindPFlags binds a full flag set to the configuration, using each flag's long
1060// name as the config key.

Callers 3

TestUnmarshalExactFunction · 0.80
UnmarshalExactFunction · 0.80

Calls 5

defaultDecoderConfigMethod · 0.95
AllKeysMethod · 0.95
decodeStructKeysMethod · 0.95
getSettingsMethod · 0.95
decodeFunction · 0.85

Tested by 2

TestUnmarshalExactFunction · 0.64