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

Method Unmarshal

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

Source from the content-addressed store, hash-verified

937}
938
939func (v *Viper) Unmarshal(rawVal any, opts ...DecoderConfigOption) error {
940 keys := v.AllKeys()
941
942 if v.experimentalBindStruct {
943 // TODO: make this optional?
944 structKeys, err := v.decodeStructKeys(rawVal, opts...)
945 if err != nil {
946 return err
947 }
948
949 keys = append(keys, structKeys...)
950 }
951
952 // TODO: struct keys should be enough?
953 return decode(v.getSettings(keys), v.defaultDecoderConfig(rawVal, opts...))
954}
955
956func (v *Viper) decodeStructKeys(input any, opts ...DecoderConfigOption) ([]string, error) {
957 var structKeyMap map[string]any

Calls 5

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