I am working on my first real Go project and have been looking for some tools to handle configuration.
Finally, I found this tool: https://github.com/spf13/viper , which is really good, but I have some problems when I try to handle more complex configurations, such as the following config.yaml example:
app: name: "project-name" version 1 models: modelA: varA: "foo" varB: "bar" modelB: varA: "baz" varB: "qux" varC: "norf"
I do not know how to get values ββfrom modelB, for example. Looking at the lib code, I found the following, but I really don't understand how to use it:
What I want is to be able, from all sides, to do something like this in my package:
modelsConf := viper.Get("models") fmt.Println(modelsConf["modelA"]["varA"])
Can someone explain to me the best way to achieve this?
source share