spf13 / viper

Go configuration with fangs
MIT License
26.85k stars 2.01k forks source link

'DateFormat' expected type 'string', got unconvertible type 'time.Time', value: '2006-01-02 00:00:00 +0000 UTC #1411

Open tinnkai opened 2 years ago

tinnkai commented 2 years ago

Preflight Checklist

Viper Version

1.12.0

Go Version

1.19

Config Source

Files

Format

YAML

Repl.it link

No response

Code reproducing the issue

func mapTo(key string, out interface{}) {
    err := viper.UnmarshalKey(key, out)
    if err != nil {
        panic(fmt.Errorf("setting unable to decode into struct: %v", err))
    }
}

Expected Behavior

nothing

Actual Behavior

panic: setting unable to decode into struct: 2 error(s) decoding:

Steps To Reproduce

No response

Additional Information

yaml file dateFormat: 2006-01-02 dateTimeFormat: 2006-01-02 15:04:05

v1.11.0 There is no such problem in the version

github-actions[bot] commented 2 years ago

👋 Thanks for reporting!

A maintainer will take a look at your issue shortly. 👀

In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.

⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9

📣 If you've already given us your feedback, you can still help by spreading the news, either by sharing the above link or telling people about this on Twitter:

https://twitter.com/sagikazarmark/status/1306904078967074816

Thank you! ❤️

sagikazarmark commented 1 year ago

Please provide a fully functional example (preferably on repl.it, please see the readme for an example)