Open maxmeyer opened 7 years ago
Did a solution come up in the end? I'm still experiencing the same issue with viper v1.2.0
Still an issue on viper v1.7.1.
For everyone stumbling upon this issue. As a workaround you can use Unmarshal
on the root viper instance and construct a struct inline, e.g.:
var c config
v.Unmarshal(&struct{ Sub *config }{&c})
If you need to support environments were no config file is a supported option, be careful to not run into: https://github.com/spf13/viper/issues/1023
Currently the safest option without any issues is to fallback to constructing the struct
using v.Get*
methods.
The use of
#Unmarshal
causes a nil pointer error ifcfg
is a#Sub
.The function is called this way:
Using viper as configuration reader, I got this error
The following line seems to cause this error: https://github.com/spf13/viper/blob/master/viper.go#L1329.