Open dtrinh100 opened 3 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! ❤️
I tried your example, just add one line and everything will be fine.
viper.SetConfigType("env")
viper.AddConfigPath(".")
+ viper.SetConfigFile(".env")
func New() *Viper {
...
v.configName = "config"
this is the root cause of your issue. by specifying extension only viper assumes you're searching for config.env
file. so use SetConfigFile
as specified above please
Expected behavior (what you expected to happen):
For it to read in the config from the .env file and map it to the struct.
Actual behavior (what actually happened):
I get the following error:
While parsing config: line
app:doesn't match format
Repl.it link:
Code reproducing the issue:
.env:
config.go:
main.go
Environment:
Anything else we should know?: