Closed mrz1836 closed 7 months 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! ❤️
I think I figured it out:
Changed my config to be a value instead of a pointer:
_appConfig := Config{
AWS: &AWSConfig{},
Datastore: &DatastoreConfig{},
Email: &EmailConfig{},
Services: &Services{},
}
vs my old way:
_appConfig := &Config{
AWS: &AWSConfig{},
Datastore: &DatastoreConfig{},
Email: &EmailConfig{},
Services: &Services{},
}
Now you unmarshal into a pointer of a value
// Unmarshal into values struct
if err = viper.Unmarshal(&_appConfig); err != nil {
err = fmt.Errorf("error loading viper values: %w", err)
logger.Data(2, logger.ERROR, err.Error())
return nil, err
}
Preflight Checklist
Viper Version
1.18.0
Go Version
1.20
Config Source
Environment variables, Files
Format
JSON
Repl.it link
No response
Code reproducing the issue
Expected Behavior
Our project has been using viper for the past year with no issues. Just installed the new version and now we cannot load our config.
Actual Behavior
Received unexpected error: error loading viper values: '' expected a map, got 'ptr'
Steps To Reproduce
Working on steps to reproduce since I cannot copy our private code into this issue tracker.
Additional Information
For now we will be targeting the previous release of Viper.
Is there something that changed in this new version that would should be aware of?