| 937 | } |
| 938 | |
| 939 | func (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 | |
| 956 | func (v *Viper) decodeStructKeys(input any, opts ...DecoderConfigOption) ([]string, error) { |
| 957 | var structKeyMap map[string]any |